我通过网络搜索找到了以下代码,但我不明白作者为什么在该类中使用枚举。是为了价值限制吗?是这样吗?WhichSex 只能采用 'Male' 和 'Female' 字符串值?
public class Person
{
public enum Sex
{
Male,
Female,
}
public string Name { get; set; }
public bool Moustache { get; set; }
public bool Goatee { get; set; }
public bool Beard { get; set; }
public Sex WhichSex { get; set; }
public double Height { get; set; }
public DateTime BirthDate { get; set; }
public bool Favorite { get; set; }
}