C# unknown types
public T Deserialize<T>(string input);
and object
object deserialzeType;
how i can parse it class type from ob开发者_如何学运维ject into into this function ?
Deserialize<deserialzeType>("text");
I am trying deserealize HttpWebResponse into concrete type, but i want to do dynamically. I want call function GetResopnse and in input parameter, class for deserialing into. Something like this:
ParseIntoClass result = HttpResponse.GetRespond(ParseIntoClass);
As Joel said, when using generic types, you cannot dynamically set the type for objects at run time.
In your snippet
Deserialize<deserialzeType>("text");
"deserializeType" must be a Type recognized by the compiler - it cannot be an Type variable that you've set to be some type recognized by the compiler.
精彩评论