Код: Выделить всё
class Null {
public static implicit operator T (Null unused) {
return null;
}
}
Код: Выделить всё
foo(T1 x) { ... }
foo(T2 x) { ... }
foo(null); // ambiguous
Код: Выделить всё
foo((T1)null); // Discovering T1 over T2 is not possible or really hard to do
Код: Выделить всё
foo(Null x) {...}
Код: Выделить всё
foo(new Null()); // not ambiguous
Код: Выделить всё
T1 x = new Null();
Можно ли написать такой класс?
Подробнее здесь: https://stackoverflow.com/questions/250 ... eturn-type
Мобильная версия