Tags

Let’s work with a very simple example in c#. I will not discuss more abut data types in this section [but later] but I will show you inserting thing [really to me]

Int32 i = 100;
object o = null;
o = new object();
System.Console.WriteLine(“The type is:{0}”, i.GetType());    // will print System.Int32
System.Console.WriteLine(“The type is:{0}”, o.GetType());   // will print System.Object
o = i; // Implicit conversion [boxing]
System.Console.WriteLine(“The type is:{0}”, o.GetType());   //will print System.Int32—? but its object  and points to Int32.

As soon as I have assigned the integer to the object the object is of type Int32. So  overcareful when you face this type conversion and work on determining data type. See the output below:

output2

Advertisements