I have an object that is passed to me as ISomething. I need to serialize the object however my serilizer expects a type parameter of a concrete type i.e:
string xml = Utilities.Serialize<ConcreteType>(myObject);
Basically I want to to the same thing as this guy: Creating a generic object based on a Type variable
however I dont want to create a new instance of an object I want to use the resulting type as a parameter to my generic class.
So my question in a nutshell is how do I create some variable that represents the concrete type of some object that I can use with a generic class like this:
string xml = Utilities.Serialize<ConcreteType>(myObject);
where ConcreteType is what I need to create.
Utilities.SomeMethod<someVariableContainingConcreteType>(myObject)Serialize()generic? There doesn't seem to be a good reason for that. If the type really is necessary, maybe an overload that takesTypeas normal parameter would be better.