Castle.MonoRail.Framework.Helpers.FormHelper.EnumToPairs C# (CSharp) Метод

EnumToPairs() публичный статический Метод

Creates a list of pairs for the enum type.
public static EnumToPairs ( Type enumType ) : string>[].Pair
enumType System.Type enum type.
Результат string>[].Pair
		public static Pair<int, string>[] EnumToPairs(Type enumType)
		{
			if (enumType == null) throw new ArgumentNullException("enumType");
			if (!enumType.IsEnum) throw new ArgumentException("enumType must be an Enum", "enumType");

			Array values = Enum.GetValues(enumType);
			string[] names = Enum.GetNames(enumType);

			List<Pair<int, string>> listOfPairs = new List<Pair<int, string>>();
			int index = 0;

			foreach(string name in names)
			{
				int value = Convert.ToInt32(values.GetValue(index++));
				listOfPairs.Add(new Pair<int, string>(value, TextHelper.PascalCaseToWord(name)));
			}

			return listOfPairs.ToArray();
		}