Making a variable of System.ValueType

As we all know that all the primitive types like Int32, double etc comes from the System.ValueType class. Ever wonder that what will happen if you make a variable of System.ValueType. Try something like this:
 
System.ValueType a; 
a = -0.33442; 
Response.Write(a.GetType());  // This will print double 
a = 2;
Response.Write(a.GetType());  // This will print Int32
Basically it will take any form of primitive type that you will assign to it. pretty cool right :)

Print | posted @ Tuesday, June 21, 2005 11:28 AM

Twitter