Why C# calls different overloaded method for different values of same type?
- by Fabio Veronez
Hello all,
I have one doubt concerning c# method overloading call resolution.
Let's suppose I have the following C# code:
enum MyEnum { Value1, Value2 }
public void test() {
method(0); // this calls method(MyEnum)
method(1); // this calls method(object)
}
public void method(object o) {
}
public void method(MyEnum e) {
}
Note that I know how to make it work but I would like to know why for one value of int (0) it calls one method and for another (1) it calls another. It sounds awkward since both values have the same type (int) but they are "linked" for different methods.
Ps.: This is my first question here, i'm sorry if I made something wrong. =P