What is the implicit conversion in C# programming?

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

In C#, We can convert instances of compatible types, which creates a new value from the old one.
Implicit conversions will happen automatically and hence they are also called as normal conversions.

Example,
int x = 5;

long y = x;
In the above example, we are converting a 32 bit integer (int) to a 64 bit integer (long) implicitly (normally).

There are some conditions that must be satisfied to allow the implicit conversions. They are,
-Implicit conversions can be allowed only if the compiler guarantee's the success of conversion.
-Implicit conversions can be allowed only if there will be no loss of information in the conversion process.


Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response