Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. void Main()
  2. {
  3. var d = new Dog();
  4. var c1 = (Cat)d; // yes
  5. 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
  6.  
  7. }
  8.  
  9. // Define other methods and classes here
  10.  
  11. class Cat
  12. {
  13. }
  14.  
  15. class Dog
  16. {
  17. public implicit operator Cat(Dog d)
  18. {
  19. return new Cat();
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement