Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Serialzator
- {
- public static void Serialize<T>(string FileName, T obj)
- {
- if (obj is ISerializable)
- {
- FileStream fs = new FileStream(FileName,FileMode.Create);
- File.Open(FileName,FileMode.Open);
- BinaryFormatter bf = new BinaryFormatter();
- bf.Serialize(fs, obj);
- fs.Close();
- }
- }
- public static T Deserialize<T>(string FileName)
- {
- FileStream fs = new FileStream(FileName,FileMode.Open);
- BinaryFormatter bf = new BinaryFormatter();
- T obj = (T)bf.Deserialize(fs);
- fs.Close();
- return obj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement