我可以在创建对象之前计算一个类中的属性数量吗?我可以在构造函数中做到吗?我可以在创建对象之前计数属性吗?在构造函数中?
class MyClass
{
public string A { get; set; }
public string B { get; set; }
public string C { get; set; }
public MyClass()
{
int count = //somehow count properties? => 3
}
}
谢谢
啊那是多么容易它是。 Sry,我认为它更难 - 认为在我创建一个对象之后,但在没有一个对象之前我很容易理解它的性质。 Thx – miri 2012-07-24 14:21:34
即使您没有它的实例,该类型对运行时也是已知的。 – sloth 2012-07-24 14:23:52