I've made the following test code:
public enum Test
{
One = 1,
Two = 2
}
public class User
{
public Test Flag { get; set; }
}
Which I use like this:
var user = new User();
var value = typeof(Test).GetField(user.Flag.ToString());
Value will be null
since it seems like User.Flag
is initialized with 0
. Why is that? 0
is not a valid value for my enum. Shouldn't it be initialized with the first valid value (1
)?