Newbie: When to use typeof() function

  • Thread starter Thread starter GiJeet
  • Start date Start date
How do feel about my last attempt at discerning the difference:
...the distinction is, like most things in C#, case-sensitive.
"Type" is an actual C# object, "type" is the English word we use to
describe the kind of data the variable holds.

That is pretty good, because we programmers are always using phrases like
"data type." Type (as in System.Type) is really the new guy on the block.
 
Ignacio said:
No really,it return an instance of a class that has info regarding the
type. Using the returned instance you can know the properties, method,
etc of the type.
You use it to know the details of a type.

Or more succinctly, typeof(T) returns the metadata for type T. This
metadata is held in an instance of the class System.Type.

And yes, you can say typeof(System.Type), which will let you see the
metadata of the metadata-holding class.
 

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

Similar Threads

about typeof 3
usable of typeof 9
typeof() 4
How to find default value for value type 2
Enum Extentions 7
typeof keyword 4
Can I use typeof() to make new objects? 11
Opposite of typeof /GetType() 3

Back
Top