Casting on run-time in C#
When I wanted a generic object extended from a class, in Java I used to write:
Class<AuthenticationProvider> c1;
What am I supposed to write in C# to do the same? How can I cast a Type Class Object in this format (a generic class extended from Authentication 开发者_JAVA百科provider)?
Do you mean Type.MakeGenericType?
Edit:
Oops, I see what you mean now. No, you can't do this in C#, because System.Type is not a generic type! It contains information about a type, but there's nothing generic about it, so typeof(Foo) does not give you Type<Foo>.
I don't see why you'd need it either, though.
加载中,请稍侯......
精彩评论