开发者

GetType on generic types

I'm trying register presenters with Windsor using the convention based method but trying to do this in VB.NET, but the problem is it does not want to compile this statement:

Dim type = GetType(AbstractPresenter(Of))

I am getting : Too few type arguments to AbstractPresenter(Of TView, TPresenter)

Which I d开发者_开发技巧on't understand because this is a valid statement according to question. Also showing valid in other C# to VB.NET converters when converting typeof(AbstractPresenter<>).

Any ideas?


There are two type arguments, and you need to specify this, just as you would do for multi-dimensional arrays:

Dim type = GetType(AbstractPresenter(Of ,))

Looks weird, but now the compiler knows that AbstractPresenter expects two type arguments.

By the way, C# has the same requirement. So the above would be written as:

var type = typeof(AbstractPresenter<,>);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜