cs-12.cs 334 B

12345678910111213141516171819202122232425262728293031323334
  1. class Y {
  2. byte b;
  3. public static implicit operator int (Y i)
  4. {
  5. return i.b;
  6. }
  7. // public static implicit operator byte (Y i)
  8. // {
  9. // return i.b;
  10. // }
  11. public Y (byte b)
  12. {
  13. this.b = b;
  14. }
  15. }
  16. class X {
  17. static void Main ()
  18. {
  19. Y y = new Y (1);
  20. switch (y){
  21. case 0:
  22. break;
  23. case 1:
  24. break;
  25. }
  26. int a = y;
  27. }
  28. }