fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. List<int> list = new List<int>(); // an empty List<T>
  9. Type type = list.GetType().GetProperty("Item").PropertyType; // System.Int32
  10. bool isEnum = type.IsEnum; // of course false
  11. Console.WriteLine("Is {0} an enum? {1}",type,isEnum);
  12. List<DayOfWeek> days = new List<DayOfWeek>();
  13. type = days.GetType().GetProperty("Item").PropertyType;
  14. isEnum = type.IsEnum; // true
  15. Console.WriteLine("Is {0} an enum? {1}",type,isEnum);
  16. }
  17. }
Success #stdin #stdout 0.03s 36888KB
stdin
Standard input is empty
stdout
Is System.Int32 an enum? False
Is System.DayOfWeek an enum? True