I have an enum that I\'d like to display all possible values of. Is there a way to get an array or list of all the possible values of the enum instead of manually creating s
You may want to do like this:
public enum Enumnum {
TypeA = 11,
TypeB = 22,
TypeC = 33,
TypeD = 44
}
All int values of this enum is 11,22,33,44.
You can get these values by this:
var enumsValues = Enum.GetValues(typeof(Enumnum)).Cast().ToList().Select(e => (int)e);
string.Join(",", enumsValues) is 11,22,33,44.