文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>序列化

序列化

时间:2010-12-03  来源:D.sky

        private void btnDe_Click(object sender, EventArgs e)
        {
            FileStream fs = new FileStream(@"D:\hhh.txt",FileMode.Open);
            BinaryFormatter bf = new BinaryFormatter();
           
            computer com = (computer)bf.Deserialize(fs);
            MessageBox.Show(com.Color+"  "+com.price);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("server=.;database=pubs;uid=sa;pwd=");
            SqlCommand cmd = new SqlCommand("select * from employee", con);

            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            
          
        }

        private void btnXML_Click(object sender, EventArgs e)
        {
            computer com1 = new computer { price = "4000", Color = "blue" };
            computer com2 = new computer { price = "3000", Color = "red" };
            computer[] co = { com1, com2 };
            XmlSerializer xs = new XmlSerializer(typeof(computer[]));
            FileStream fs = new FileStream(@"D:\xml.xml", FileMode.CreateNew);

            xs.Serialize(fs, co);
           
            fs.Flush();
            fs.Close();
        }

        private void btnDeXML_Click(object sender, EventArgs e)
        {
            XmlSerializer xs = new XmlSerializer(typeof(computer[]));
            FileStream fs = new FileStream(@"D:\xml.xml", FileMode.Open);

            computer[]c=(computer[])xs.Deserialize(fs);
            MessageBox.Show(c.Length.ToString());

            fs.Flush();
            fs.Close();
        }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载