Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using System.Runtime.Serialization.Formatters.Binary;
  11.  
  12. namespace test
  13. {
  14. public partial class Form1 : Form
  15. {
  16. [Serializable]
  17. public class ore
  18. {
  19. public float Titan;
  20. public float Eperton;
  21. }
  22. ore b1 = null;
  23. ore b2 = null;
  24.  
  25. public Form1()
  26. {
  27. InitializeComponent();
  28.  
  29. ore b2 = new ore();
  30. ore b1 = new ore();
  31. }
  32.  
  33. private void textBox1_TextChanged(object sender, EventArgs e)
  34. {
  35. float tempFloat;
  36. if (float.TryParse(textBox1.Text, out tempFloat)); {
  37. b1.Titan=tempFloat;
  38. }
  39.  
  40. else
  41. {
  42. MessageBox.show ("oh shit");
  43. }
  44.  
  45.  
  46. }
  47.  
  48. private void textBox2_TextChanged(object sender, EventArgs e)
  49. {
  50.  
  51. b2.Eperton = float.Parse(textBox1.Text);
  52.  
  53. }
  54.  
  55.  
  56. private void button1_Click(object sender, EventArgs e)
  57. {
  58. List<ore> oreData = new List<ore>();
  59. oreData.Add(b1);
  60. oreData.Add(b2);
  61.  
  62. FileStream fs = new FileStream("ore.dat", FileMode.Create);
  63. BinaryFormatter bf = new BinaryFormatter();
  64. bf.Serialize(fs, ore);
  65. fs.Close();
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement