fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public interface I {}
  6.  
  7. public class A : I {}
  8.  
  9.  
  10. public class Test
  11. {
  12. public static void foo(List<I> list)
  13. => Console.WriteLine(list.Count);
  14.  
  15. public static void bar(IEnumerable<I> list)
  16. => Console.WriteLine(list.Count());
  17.  
  18. public static void Main()
  19. {
  20. var list = new List<A> {
  21. new A(),
  22. new A()
  23. };
  24.  
  25. foo(list.Cast<I>().ToList());
  26. bar(list);
  27. }
  28. }
Success #stdin #stdout 0.02s 16860KB
stdin
Standard input is empty
stdout
2
2