fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var myList = Get<List<int>>();
  9. Console.WriteLine(myList.Count); // Should be 1
  10. }
  11.  
  12. private static T Get<T>() where T: ICollection<int>
  13. {
  14. T coll = Activator.CreateInstance<T>();
  15. int a = 1;
  16.  
  17. coll.Add(a);
  18. return coll;
  19. }
  20. }
Success #stdin #stdout 0.04s 34000KB
stdin
Standard input is empty
stdout
1