Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- Settings s = new Settings();
- s.Setting1 = 1.45;
- s.Setting2 = 5.04;
- using (StreamWriter sw = new StreamWriter("test.txt"))
- {
- sw.WriteLine(System.Text.Encoding.Default.GetString(Serialize(s)));
- }
- }
- public static byte[] Serialize(object anySerializableObject)
- {
- using (var memoryStream = new MemoryStream())
- {
- (new BinaryFormatter()).Serialize(memoryStream, anySerializableObject);
- return memoryStream.ToArray();
- }
- }
- }
- [SerializableAttribute]
- public class Settings
- {
- public double Setting1;
- public double Setting2;
- }
- /*
- OUTPUT
- ÿÿÿÿ JConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null ConsoleApplication1.Settings Setting1Setting2 333333÷?)\Âõ(@
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement