InterviewSolution
| 1. |
What Are The 2 Kinds Of Data Type Conversions In C#? |
|
Answer» Implicit conversions: No special SYNTAX is required because the conversion is TYPE safe and no data will be lost. Examples include conversions from smaller to larger INTEGRAL types, and conversions from derived classes to base classes. Explicit conversions: Explicit conversions require a cast operator. The source and destination variables are COMPATIBLE, but there is a risk of data LOSS because the type of the destination variable is a smaller size than (or is a base class of) the source variable. Implicit conversions: No special syntax is required because the conversion is type safe and no data will be lost. Examples include conversions from smaller to larger integral types, and conversions from derived classes to base classes. Explicit conversions: Explicit conversions require a cast operator. The source and destination variables are compatible, but there is a risk of data loss because the type of the destination variable is a smaller size than (or is a base class of) the source variable. |
|