Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class C {
- abstract C SomeOp();
- }
- class A : C {
- C SomeOp() {
- return SomeOp() as A;
- }
- A SomeOp() {
- return this;
- }
- }
- class B : C {
- C SomeOp() {
- return SomeOp() as B;
- }
- B SomeOp() {
- return this;
- }
- }
- class Foo {
- void Bar() {
- A a = new A();
- B b = new B();
- A otherA = a.SomeOp(); // no cast needed type inferred
- B otherB = b.SomeOp(); // no cast needed type inferred
- C c = a.SomeOp(); // no cast needed, type inferred
- c.SomeOp(); // not ambiguous, only one method with this name
- a.SomeOp() as A; // ambigous without assignment
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment