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.
 
Back
Top