What is equivelant to VB.NET GetType()

  • Thread starter Thread starter Daniel Billingsley
  • Start date Start date
D

Daniel Billingsley

Using this keyword in VB I can do

Dim typeData As Type = GetType(myClass)

which returns a Type of course. I can't find quite the same thing in C# or
the framework.

Will the following meet the needs like the above VB code? (If so, then why
the keyword in VB???)

Type typeData = Type.GetType("myClass")
 
If "myClass" is the name of your class, you can use typeof(myClass). If
it's an instance of your class, you can use myClass.GetType().
 
Thanks to both of you, that worked poifect.

Pardon me for being a bit misleading... I should have used MyClass as I
indeed meant to refer to the class, not an instance object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top