Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Runtime.Serialization.Formatters.Binary;
- using System.IO;
- [Serializable]
- public class UserPrefs
- {
- public string WindowColor;
- public int FontSize;
- }
- static class Program
- {
- [STAThread]
- static void Main()
- {
- UserPrefs userData = new UserPrefs();
- userData.WindowColor = "Yellow";
- userData.FontSize = 50;
- BinaryFormatter binFormat = new BinaryFormatter();
- // Сохранить объект в локальном файле.
- using (Stream fStream = new FileStream("user.xml",
- FileMode.Create, FileAccess.Write, FileShare.None))
- {
- binFormat.Serialize(fStream, userData);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement