Re: how to find the type of an object represented by an interface



Okay. Actually, I found the answer (seems I always stumble on it shortly
after posting), but it led to another problem.

Sub GetNewObjectOfType(ByVal sender As IGenericInference)
Dim o As Object = sender
Dim T As Type = o.GetType()

'now, what I need to do is call a method that takes a generics argument
Dim newobject as Object = SomeObjectOfType(Of T)()
End Sub

Function SomeObjectOfType(Of T As IGenericInference)() As T
(code to create new object of type T)
End Function

Looks like I can't call SomeObjectOfType(Of T)() with a variable as a
reference. Weird, because if T was passed into the Sub via a generics Of
statement I would be able to pass it on.

"Milosz Skalecki [MCAD]" <mily242@xxxxxxxxxxxxxxxxx> wrote in message
news:F0266DD5-BAE1-4288-A06D-A23D004BBBC9@xxxxxxxxxxxxxxxx
Show us the code
--
Milosz


"Random" wrote:

How can I use reflection (or some other method) to find the type of an
object that has been passed in to my method under an interface
definition?

I try to use GetType, but that won't work.





.



Relevant Pages

  • Re: DropDownList SelectedIndex problem in C# (from working VB.NET)
    ... > Private Sub Page_Load(ByVal sender As System.Object, ... > Sub BindData() ... > Dim objConn As New SqlConnection ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: Filewatch saga continues
    ... Public Sub NKWatch_Created(ByVal sender As Object, ... Dim frmFirst As New Form1 ...
    (microsoft.public.dotnet.general)
  • Re: Filewatch saga continues
    ... Public Sub NKWatch_Created(ByVal sender As Object, ... Dim frmFirst As New Form1 ...
    (microsoft.public.dotnet.general)
  • Re: How to choose what control will receive action
    ... You can use the sender parameter of the button click event. ... > Dim myRadio As RadioButtonList ... > Private Sub Page_Load(ByVal sender As System.Object, ... > LabelText As String, ByVal Type As String) ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Freeze Column in DataGrid
    ... > Dim mForeColor As Color = Color.Black ... > Public Sub New ... > Private Sub dg_Scroll(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)