3

I know I can get a System.Type of an instance of my class by using GetType()

Point pt = new Point(0, 0); System.Type ptType = pt.GetType(); 

But what can I do when I want get System.Type of a type:

System.Type pointType = Point.GetType(); 

It does not work, but how can I do this?

1 Answer 1

15

You could use the typeof expression:

System.Type pointType = typeof(Point); 

The GetType method is used to get the runtime type, whereas the typeof expression gets the compile-time type.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.