If I have a class with an enum
member and I want to be able to represent situations where this member is not defined, which is it better?
a) Declare the member as nullable in the class using nullable types. E.g.:
public SomeEnum? myEnum;
b) Add a default, 'unknown' value to the enumeration. E.g.:
public enum SomeEnum {
Unknown,
SomeValueA,
SomeValueB,
SomeValueC,
}
I can't really see any major pros/cons either way; but perhaps one is preferable over the other?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…