fork download
  1. using System.Collections.Generic;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. var item = new Foo();
  8. var inner = new List<Foo>();
  9. var outer = new List<List<Foo>>();
  10.  
  11. inner.Add(item);
  12. outer.Add(inner);
  13.  
  14. IEnumerable<IEnumerable<Foo>> data = outer;
  15.  
  16. foreach (Foo foo in data)
  17. {
  18. foo.Bar();
  19. }
  20. }
  21. }
  22.  
  23. public class Foo
  24. {
  25. public void Bar()
  26. {
  27. }
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(14,39): error CS0266: Cannot implicitly convert type `System.Collections.Generic.List<System.Collections.Generic.List<Foo>>' to `System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<Foo>>'. An explicit conversion exists (are you missing a cast?)
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty