开发者

C# ITypeResolutionService for constructed types

My ITypeResolutionService is failing to return correct type for constructed type in an assembly:

e.g. "abc`N[aaa,bbb`1[string],....,mmm]"

how to get type information for this type.

I can get type for ab开发者_Python百科c'N from the referenced assembly. Then i have to call makegenericType(Type[]) on this type in order to get constructed type. Is there any efficient way to parse the type arguments within the sqaure brackets in C#. and as shown above type arguments can itself be constructed type e.g. bbb`1[string].

Wonder if .net provides any standard API for this.

Thanks Prasad


Type.GetType(string) supports this. For example, if I run the following:

var type = Type.GetType("System.Collections.Generic.List`1[System.String]");

I get a constructed type representing a list of strings.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜