nyk0r

Untitled

Aug 1st, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.31 KB | None | 0 0
  1. /*
  2. The (type) notation has two semantics with the same syntax.
  3. The first is for type casting and second is for unboxing.
  4. */
  5.  
  6.  
  7. double a = 2.3;
  8. object b = (object) a;
  9. double c = (double) b;     // ok
  10.  
  11. double x = 4.2;
  12. object y = (object) x;
  13. int z = (int)y;            // System.InvalidCastException on unboxing.
Advertisement
Add Comment
Please, Sign In to add comment