开发者

Get Type Of a Type

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开发者_如何学C does not work, but how can I do this?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜