I have a pseudo-enum class that consists of a protected constructor and a list of readonly static properties:
public class Column
{
protected Column(string name)
{
columnName = name;
}
public readonly string columnName;
public static readonly Column UNDEFINED = new Column("");
public static readonly Column Test = new Column("Test");
/// and so on
}
I want to access individual instances by their string name, but for some reason, the reflection does not return the static properties at all:
In the above image, you can see that the property exists and has a non-null value, yet if I query it using reflection, I get null
.
If I try to query the property list, I get an empty array:
PropertyInfo[] props = typeof(Column).GetProperties(BindingFlags.Static);
if (props.Length == 0)
{
// This exception triggers
throw new Exception("Where the hell are all the properties???");
}
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire