Of course, like everything in life, that depends. You can use binary serialization to do it:
Type theType = typeof(RectangleF);
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(@"C:\MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, theType);
stream.Close();
stream =
new FileStream(@"C:\MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read);
Type theNewType = (Type)formatter.Deserialize(stream);
stream.Close();
Now do you mean an actual "Type" object or something like saving "public class MyClass" to a file So far as I can tell, you can't use XmlSerialization on the Type object but binary works.
Saving type object to a file
Mindking
Of course, like everything in life, that depends. You can use binary serialization to do it:
Type theType = typeof(RectangleF); IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(@"C:\MyFile.bin", FileMode.Create, FileAccess.Write, FileShare.None);formatter.Serialize(stream, theType);
stream.Close();
stream =
new FileStream(@"C:\MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); Type theNewType = (Type)formatter.Deserialize(stream);stream.Close();
Now do you mean an actual "Type" object or something like saving "public class MyClass" to a file So far as I can tell, you can't use XmlSerialization on the Type object but binary works.