注册 登录
编程论坛 C# 论坛

messagebox.show问题

花间酒 发布于 2017-09-06 09:36, 2342 次点击
想在弹出的窗体上显示前面写的结构体的信息,注释是我尝试过的方法,代码如下:
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using

namespace address1
{
    public struct mes {
        public string name;
        public string address;
        public string telephone;
    }

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            FileStream fs = File .Create("C:\\store.txt");
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(textBox1 );
            sw.WriteLine(textBox2 );
            sw.WriteLine(textBox3 );
            fs.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            mes  obj=new mes ();
            StreamReader sr = new StreamReader("C:\\store.txt");
            obj.name = sr.ReadLine();
           // MessageBox .Show ();
            obj.telephone = sr.ReadLine();
           // MessageBox .Show (obj .telephone );
            obj.address = sr.ReadLine();
            //MessageBox .Show ("",obj.telephone );
            /*Console.WriteLine("{0}",obj .name );
            Console.WriteLine("{0}",obj .telephone );
            Console.WriteLine("{0}",obj .address );*/

        }
    }
}
3 回复
#2
winners2017-09-06 10:49
            FileStream fs = File.Create("C:\\store.txt");
            StreamWriter sw = new StreamWriter(fs);
 sw.WriteLine(textBox1.Text);
            sw.WriteLine(textBox2.Text);
            sw.WriteLine(textBox3.Text);
//
            sw.Close();
            fs.Close();
#3
花间酒2017-09-12 20:19
按着您的方法做了,但是出现如下情况
只有本站会员才能查看附件,请 登录

还请各位大神们再指教一下
#4
winners2017-09-15 23:46
你这是点击了好多次按钮吧 还是放进循环里了  正常 点一次按钮写一次
1