This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 11th, 2012  |  syntax: C#  |  size: 0.76 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class Program
  2.     {
  3.         public static void Write(MyInt v)
  4.         {
  5.             //Console.WriteLine("{0}", v.v is byte);
  6.         }
  7.         static void Main(string[] args)
  8.         {
  9.             Write((byte)2);
  10.         }
  11.     }
  12.     public struct MyInt2
  13.     {
  14.         public object v;
  15.         public MyInt2(byte vv) { v = vv; }
  16.         public MyInt2(short vv) { v = vv; }
  17.         public MyInt2(byte[] vv) { v = vv; }
  18.         public static implicit operator MyInt2(byte vv) { return new MyInt2 { v = vv }; }
  19.         //public static extern implicit operator MyInt(int vv);
  20.     }
  21.     struct MyInt
  22.     {
  23.         public MyInt2 v;
  24.         MyInt(MyInt2 vv) { v = vv; }
  25.         public static implicit operator MyInt(MyInt2 vv) { return new MyInt { v = vv }; }
  26.     };
clone this paste RAW Paste Data