A
Andrew Backer
I hope someone out there can help me with this, because I am stuck.
My problem is that I have an instance of a generic class, but I don't know
ahead of time what the type parameter used was. In my case the type must
derive from a class, like UserControl, so I at least know I should be able
to use that.
I can not figure out a way to get this as an instance of the generic class,
but with the base class as the type parameter. I am looking to do something
like this :
...Dim formRef as Form = /get-reference-to-mycontainer-instance/
...If ( TypeOf formRef Is MyContainer(Of UserControl) ) Then
....... Dim a As MyContainer(Of UserControl) = CType(formRef, MyContainer(Of
UserControl))
....... do stuff
...End If
Here is the generic class:
-------
...Public Class MyContainer(Of T As {UserControl, New})
.......Inherits System.Windows.Forms.Form
.......
...End Class
Is there any way to do something like this? Even something ugly?
Thanks,
//Andrew
My problem is that I have an instance of a generic class, but I don't know
ahead of time what the type parameter used was. In my case the type must
derive from a class, like UserControl, so I at least know I should be able
to use that.
I can not figure out a way to get this as an instance of the generic class,
but with the base class as the type parameter. I am looking to do something
like this :
...Dim formRef as Form = /get-reference-to-mycontainer-instance/
...If ( TypeOf formRef Is MyContainer(Of UserControl) ) Then
....... Dim a As MyContainer(Of UserControl) = CType(formRef, MyContainer(Of
UserControl))
....... do stuff
...End If
Here is the generic class:
-------
...Public Class MyContainer(Of T As {UserControl, New})
.......Inherits System.Windows.Forms.Form
.......
...End Class
Is there any way to do something like this? Even something ugly?
Thanks,
//Andrew