TypeOf with Generics

Before generics I could use (TypeOf myObject Is MyClass) or (TypeOf myObject Is IMyInterface) to determine whether an object is a certain class or interface type. But, now if myObject is a generic then that technique does not work because the generic could be a structure. So, I'm searching for the best (i.e., fastest) way to perform the above tests when using generics. Using (TypeOf CObj(myObject) Is MyClass) is the first thing that comes to mind, but is there a better way? For example, is it possible to specify that a generic is a reference type?

Thanks for any help.
Lance

[587 byte] By [ljlevend] at [2008-1-12]
# 1
ljlevend,
You can use a Class constraint to indicate the type parameter to your Generic type has to be a Class. For details see:

http://msdn2.microsoft.com/library/w256ka79(en-us,vs.80).aspx

and

http://msdn2.microsoft.com/library/ms172922(en-us,vs.80).aspx

Hope this helps
Jay

JayB.Harlow at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2
Great! Thank you.

Lance

ljlevend at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic Language...