language: C# (mono-2.8)
date: 240 days 21 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System;
using System.Collections.Generic;
 
public class Test
{
        public static void Main()
        {
                List<int> list = new List<int>(); // an empty List<T>
                Type type = list.GetType().GetProperty("Item").PropertyType; // System.Int32
                bool isEnum = type.IsEnum; // of course false
                Console.WriteLine("Is {0} an enum? {1}",type,isEnum);
                List<DayOfWeek> days = new List<DayOfWeek>();
                type = days.GetType().GetProperty("Item").PropertyType;
                isEnum = type.IsEnum; // true
                Console.WriteLine("Is {0} an enum? {1}",type,isEnum);
        }
}