How can I convert my Class1
or class of object to a String
and then convert the String
back to a type that I can use for instantiation ?
Something like that:
// class to string:
Type type1 = myObject.GetType();
string text = type1.ToString();
// and then back
Type type2 = Type.Parse(text);
// type2 should reflect the same type as type1
To do that with enums is really easy and nice. So I would like to have that with classes. I also want to avoid using serialization and XML. I don't want to serialize objects but JUST to remember the class I need to instantiate for an object.