Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Unexpect method calls with extentions overloads

$
0
0

Hi,

I have the following code 

void Main()
{
    var a = new A();
	a.Foo(1);
	a.Foo(0);
}

public enum MyEnum
{
  None = 0,
  One = 1
}


public class A
{
  public void Foo(MyEnum en)
  {
    Console.WriteLine("MyEnum");
  }
}

public static class Extention
{
   public static void Foo(this A o, int x)
   {
      Console.WriteLine("int");
   }
}
I expect "int int" as result, but I got "int MyEnum". Is it compiler bug or some design feature?


Viewing all articles
Browse latest Browse all 8156

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>