C#.Net Type Conversion
- Type conversion is a way to convert one data type into another data type.
- In C#.Net type conversion can be done in two ways:
- Implicit Type Conversion
- Explicit Type Conversion
Implicit Type Conversion
- Implicit type conversion is a way in which one data type is converted into another data type automatically.
- No data loss occurs in the Implicit Type conversion so it is a type safe conversion.
- Implicit Type Conversion is basically used where smaller data type is converted into larger data type.
Explicit Type Conversion
- Explicit Data Type Conversion is a way in which one data type is converted into another data type with the help of some predefined functions.
- Explicit type conversion is done with the help of casting.
- In this type of conversion data loss is occur because the conversion is done forcefully. So it is not a type safe conversion.
Methods of Type Conversion in C#.net
Following table contains the various type conversion methods which are widely used in C# for the purpose of Type Conversion:
Note: you can see CSharp.Net Tutorial for more details.