System.Enum.GetNames C# (CSharp) Method

GetNames() private method

private GetNames ( Type enumType ) : String[]
enumType Type
return String[]
        public static String[] GetNames(Type enumType)
        {
            if (enumType == null)
                throw new ArgumentNullException("enumType");

            if (!(enumType is RuntimeType))
                throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType");

            if (!enumType.IsEnum)
                throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");

            // Get all of the Field names
            String[] ret = GetHashEntry(enumType).names;

            // Make a copy since we can't hand out the same array since users can modify them
            String[] retVal = new String[ret.Length];

            Array.Copy(ret, retVal, ret.Length);
            return retVal;
        }
        

Usage Example

Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();
            var carSize = Enum.GetNames(typeof(CarTypes));

            cboxCarType.ItemsSource = carSize;
        }
All Usage Examples Of System.Enum::GetNames