//---------------------------------------------------------------------------- // Copyright (C) 2013-2015 Fabrice HARROUET (ENIB) // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and // that both that copyright notice and this permission notice appear // in supporting documentation. // The author makes no representations about the suitability of this // software for any purpose. // It is provided "as is" without express or implied warranty. //---------------------------------------------------------------------------- using System; public class Test { public static void Main(string[] args) { int i=123; #pragma warning disable 183, 184 Console.WriteLine("i={0}, (i is int)={1}, (i is float)={2}", i,i is int,i is float); #pragma warning restore 183, 184 Console.WriteLine("~~~~ boxing ~~~~"); object o=i; Console.WriteLine("o={0}, (o is int)={1}, (o is float)={2}", o,o is int,o is float); Console.WriteLine("~~~~ unboxing ~~~~"); int j=(int)o; #pragma warning disable 183, 184 Console.WriteLine("j={0}, (j is int)={1}, (j is float)={2}", j,j is int,j is float); #pragma warning restore 183, 184 } } //----------------------------------------------------------------------------