Last active
December 20, 2015 20:49
-
-
Save cgatian/6193575 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Base | |
{ | |
public long _id; | |
public Base(long id) | |
{ | |
this._id = id; | |
} | |
} | |
public class A : Base | |
{ | |
public A(long id) : base(id) | |
{ | |
} | |
} | |
public class B : Base | |
{ | |
public B(long id) : base(id) | |
{ | |
} | |
public static implicit operator A(B id) | |
{ | |
return new A(id._id); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
B _b = new B(10); | |
A _a = _b; | |
Base _base = _a; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment