nyk0r

Cast on Unboxing

Jul 27th, 2011
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.18 KB | None | 0 0
  1. double a = 2.3;
  2. object b = (object) a;
  3. double c = (double) b;     // ok
  4.  
  5. double x = 4.2;
  6. object y = (object) x;
  7. int z = (int)y;            // System.InvalidCastException on unboxing.
Advertisement
Add Comment
Please, Sign In to add comment