What is the explicit conversion in C# programming?

 Posted by Goud.Kv on 9/3/2014 | Category: C# Interview questions | Views: 420 | Points: 40
Answer:

In C#, We can convert the instances of compatible types, which creates a new value from the old one.
Explicit conversions cast to convert.

Example,
int x = 5;

short y = (short)x;
In the above example, we are converting a 32 bit integer (int) to a 16 bit integer (short) by using cast (short) of that type.

Explicit conversions doesn't need any guarantee of the compiler for the successful conversion.
There might be a loss of information while converting explicitly.


Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response