[Serializable]
{
   public string WorkDir = "C:\temp";
   public int TimeOut = 2000;
}UserSettings currentSettings = new UserSettings();
currentSettings.TimeOut = 1000; // устанавливаем конкретное значениеusing System.Runtime;
...
BinaryFormatter bf = new BinaryFormatter();
using (Stream fs = new FileStream("settings.dat", FileMode.Open.
Create, FileAccess.Write, FileShare.None))
{
  bf.Serialize(fs, currentSettings);
}FileStream fs = new FileStream("settings.dat", FileMode.Open);
try
{
  BinaryFormatter bf = new BinarryFormatter();
  currentSettings = (UserSettings)bf.Deserialize(fs);
}
catch (SerializationException e)
{
  Console.WriteLine("Ошибка. Причина: " + e.Message);
  throw;
}
finally
{
  fs.Close();
}using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace Serialization
{
    [Serializable]
    class Person
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public Person(string name, int age)
        {
            Name = name;
            Age = age;
        }
    }
 class Program
    {
        static void Main(string[] args)
        {
            // объект для сериализации
            Person person = new Person("Tom", 29);
            Console.WriteLine("Объект создан");
            // создаем объект BinaryFormatter
            BinaryFormatter formatter = new BinaryFormatter();
            // получаем поток, куда будем записывать сериализованный объект
            using (FileStream fs = new FileStream("people.dat", FileMode.OpenOrCreate))
            {
                formatter.Serialize(fs, person);
                Console.WriteLine("Объект сериализован");
            }
 // десериализация из файла people.dat
            using (FileStream fs = new FileStream("people.dat", FileMode.OpenOrCreate))
            {
                Person newPerson = (Person)formatter.Deserialize(fs);
                Console.WriteLine("Объект десериализован");
                Console.WriteLine("Имя: {0} --- Возраст: {1}", newPerson.Name, newPerson.Age);
            }
            Console.ReadLine();
        }
    }
}