Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 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.  
  26.  
  27. public Form1()
  28. {
  29. InitializeComponent();
  30.  
  31. ore b2 = new ore();
  32. ore b1 = new ore();
  33. }
  34.  
  35. private void textBox1_TextChanged(object sender, EventArgs e)
  36. {
  37.  
  38. float tempFloat;
  39.  
  40.  
  41. if (float.TryParse(textBox1.Text, out tempFloat))
  42. {
  43. b1.Titan = tempFloat;
  44. }
  45. else
  46. MessageBox.Show("uh oh");
  47.  
  48.  
  49.  
  50. }
  51.  
  52. private void textBox2_TextChanged(object sender, EventArgs e)
  53. {
  54. float tempFloat;
  55. if (float.TryParse(textBox1.Text, out tempFloat))
  56. {
  57. b2.Eperton = tempFloat;
  58. }
  59. else
  60. MessageBox.Show("uh oh");
  61.  
  62.  
  63. }
  64.  
  65.  
  66. private void button1_Click(object sender, EventArgs e)
  67. {
  68. List<ore> oreData = new List<ore>();
  69. oreData.Add(b1);
  70. oreData.Add(b2);
  71.  
  72. FileStream fs = new FileStream("ore.dat", FileMode.Create);
  73. BinaryFormatter bf = new BinaryFormatter();
  74. bf.Serialize(fs, oreData);
  75. fs.Close();
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement