MBrendecke icon

Untitled

MBrendecke | PRO | 02/06/16 04:46:29 PM UTC | 0 ⭐ | 385 👁️ | Never ⏰ | []
C# |

1.49 KB

|

None

|

0 👍

/

0 👎

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Windows.Forms;
 
namespace Baustoff_Verzeichnis_mh
{
    public partial class Form1 : Form
    {
 
        CBaustoffe baustoff;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {            
            baustoff = new CBaustoffe();
            baustoff.material = "KS";
            baustoff.format = "NF";
            baustoff.lamda = 1;
            baustoff.rohdichte = 2;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = baustoff.material;
            textBox2.Text = baustoff.format;
            textBox3.Text = Convert.ToString(baustoff.rohdichte);
            textBox4.Text = Convert.ToString(baustoff.lamda);
 
            schreibeDatei();
        }
 
 
        public void schreibeDatei()
        {
            using (var fs = File.Create("Baustoffe.xml")) {
                new XmlSerializer(typeof(CBaustoffe)).Serialize(fs, baustoff);
            }
        }
 
        public void leseDatei()
        {
            using (var fs = File.Open("Baustoffe.xml")) {
                baustoff = (CBaustoffe)new XmlSerializer(typeof(CBaustoffe)).Deserialize(fs);
            }
        }
    }
}

Comments