GetType

  • Thread starter Thread starter Greg Burns
  • Start date Start date
G

Greg Burns

What the difference between these two?

System.Type.GetType("System.Int32")
and
GetType(Integer)

Or more specifically, why does GetType(Integer) work, but not
System.Type.GetType(Integer)? What namespace is the GetType function(?) part
of?

I'm confused.

Greg
 
Greg,
System.Type.GetType("System.Int32")
You are calling a shared method of the System.Type class.
GetType(Integer)
You are using a VB.NET keyword.
Or more specifically, why does GetType(Integer) work, but not
System.Type.GetType(Integer)?
Type.GetType's parameter is defined to be a String, while the GetType
keyword requires the type identifier.
What namespace is the GetType function(?) part of?
Being a keyword GetType(Integer) is not part of any namespace. Remember in
VS.NET keywords are normally Blue, while identifiers (members of classes)
are normally Black.

Hope this helps
Jay
 
A keyword! Doh!

Well since this is VB.NET keyword, what would the equivalent be for C#?

Passing the type as a string with System.Type.GetType("System.Int32") seems
crude. Why would you ever need/want to do this?

Thanks Jay

Greg
 
Well since this is VB.NET keyword, what would the equivalent be for C#?

look for typeof() in help...
 

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