Tuesday 8 July 2014

Asp.Net Type casting

It is the process of converting from one data type to another data type.
In .Net type casting are divided in to 3 types.
1. Implicit: Controlled by CLR not the programmer.
2. Explicit: Controlled by programmer.
a. C++ style of type casting.
b. parsing: which will accept i/p as only string.(String to any other data type).
Ex: int a =int.parse(String);
c. converting: It will convert all data type.
3. Boxing and unboxing:
Converting from value type to reference is boxing.
Ex: convert from int to object.
Converting reference type to value type is unboxing.
Ex: convert from object to int