Eventuali duplicati:
Type.GetFields() - only returning “public const” fieldsRiflettendo costanti proprietà/campi in .net
ho una classe che si presenta come la seguente:
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 sta cercando di riflettere si. So come riflettere i campi ONE, & DUE. Ma come faccio a sapere se è costante o no?
Effetto dupe di http://stackoverflow.com/questions/1287797 –
Riporto quello ... Non riesco a trovare i campi UNO e DUE. – deostroll
Non sono solo campi, sono campi statici, non campi istanza. –