开发者

C# unknown types

开发者 https://www.devze.com 2023-02-26 05:05 出处:网络
public T Deserialize<T>(string input); and object object deserialzeType; how i can parse it class type from ob开发者_如何学运维ject into into this function ?
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消