help.net


Musing on .Net

News

Windows Phone Apps I recommend

FotoBank


FotoIreland



hit counters






Open source CMS


My blog

Irish blogs

Locations of visitors to this page Get Chitika eMiniMalls

.Net useful

Blogs I read

PocketPC

SQL

Usability

Reflecting on Generics

Have you ever had to do something like this:

string typeName = "MyDataType";
Type type = Type.GetType( typeName );
object o = someGenericClass<typeof(type)>();

If you have, then you have also discovered that this does not compile. The good news is this capability is possible in C#, but its not obvious. This article is aimed at unmuddying the waters surrounding reflection and generic types. We will show how to accomplish this with a generic class (and, as an added bonus, the equivalent functionality for generic methods too).

Read more...

 

Posted: Dec 19 2007, 12:11 AM by help.net
Filed under:

Comments

No Comments