Olası Çoğalt:
Type.GetFields() - only returning “public const” fieldsyansıtan sabit özellikler/alanlar
ben şöyle şöyle bir sınıf var:
public class MyConstants
{
public const int ONE = 1;
public const int TWO = 2;
Type thisObject;
public MyConstants()
{
thisObject = this.GetType();
}
public void EnumerateConstants()
{
PropertyInfo[] thisObjectProperties = thisObject.GetProperties(BindingFlags.Public);
foreach (PropertyInfo info in thisObjectProperties)
{
//need code to find out of the property is a constant
}
}
}
Bascially o çalışıyor yansıtmak için kendisi. ONE, & TWO alanlarını nasıl yansıtacağımı biliyorum. Ama bir sabit olup olmadığını nasıl bilebilirim?
http://stackoverflow.com/questions/1287797 –
'un etkin bir şekilde dupe edilmesi Bunu geri alıyorum ... Alanları ONE & TWO'yu bulamıyorum. – deostroll
Sadece alanlar değil, statik alanlar, örnek alanlar değiller. –