Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Main()
- {
- var d = new Dog();
- var c1 = (Cat)d; // yes
- var c2 = d as Cat; // Cannot convert type 'Dog' to 'Cat' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion
- }
- // Define other methods and classes here
- class Cat
- {
- }
- class Dog
- {
- public implicit operator Cat(Dog d)
- {
- return new Cat();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement