Compiler Warning (level 2) CS0278

'type' does not implement the 'pattern name' pattern. 'method name' is ambiguous with 'method name'.

There are several statements in C# that rely on defined patterns, such as foreach and using. For example, foreach relies on the collection class implementing the "enumerable" pattern.

CS0278 can occur if the compiler is unable to make the match due to ambiguities. For example, the "enumerable" pattern requires that there be a method called MoveNext, and your code might contain two methods called MoveNext. The compiler will attempt to find an interface to use, but it is recommended that you determine and resolve the cause of the ambiguity.

For more information, see How to: Access a Collection Class with foreach (C# Programming Guide).

Example

The following sample generates CS0278.

// CS0278.cs
using System.Collections.Generic;
public class myTest 
{
   public static void TestForeach<W>(W w) 
      where W: IEnumerable<int>, IEnumerable<string>
   {
      foreach (int i in w) {}   // CS0278
   }
}