I have read documentation that states that ‘given the type of the enum, the GetValues() method of System.Enum will return an array of the given enum's base type’ ie int, byte etc
However I have been using the GetValues method and all I keep getting back is an array of type Enums. Am I missing something??
public enum Response
{
Yes = 1,
No = 2,
Maybe = 3
}
foreach (var value in Enum.GetValues(typeof(Response)))
{
var type = value.GetType(); // type is always of type Enum not of the enum base type
}
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…