fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace IEnumerableTest
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12.  
  13. Test.Normaltest(new Base());
  14. Test.IEnumerableTest(new Base[] { });
  15.  
  16. Test.Normaltest(new Inheritance());
  17. Test.IEnumerableTest(new Inheritance[] { });
  18.  
  19. Test.IEnumerableTest((IEnumerable<Inheritance>)new Inheritance[] { });
  20.  
  21. }
  22. }
  23.  
  24.  
  25. public static class Test
  26. {
  27. public static void Normaltest(Base obj) { }
  28. public static void IEnumerableTest(IEnumerable<Base> obj) { }
  29.  
  30. }
  31.  
  32.  
  33. public class Base
  34. {
  35.  
  36. }
  37.  
  38. public class Inheritance : Base
  39. {
  40.  
  41. }
  42.  
  43.  
  44.  
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(19,18): error CS1502: The best overloaded method match for `IEnumerableTest.Test.IEnumerableTest(System.Collections.Generic.IEnumerable<IEnumerableTest.Base>)' has some invalid arguments
prog.cs(28,28): (Location of the symbol related to previous error)
prog.cs(19,18): error CS1503: Argument `#1' cannot convert `System.Collections.Generic.IEnumerable<IEnumerableTest.Inheritance>' expression to type `System.Collections.Generic.IEnumerable<IEnumerableTest.Base>'
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty