C#
11# 열거형 카운트 알아오기
NaHyungMin
2017. 9. 22. 17:00
1 2 3 4 5 6 7 8 9 | public static Int32 EnumCount<T>() where T : IConvertible { if (!typeof(T).IsEnum) throw new InvalidDataException("EnumCount, only support enum"); Int32 index = Enum.GetNames(typeof(T)).Length - 1; return index; } | cs |
열거형의 전체 카운트를 알아오는 함수