An implicit conversion happens automatically because the compiler knows it is safe, like int to double. An explicit conversion needs a cast, like (int)largeValue, because the value may not fit.
Implicit conversions go from a smaller type to a larger one, so the value never overflows. They are not always exact, though. Converting int to float or long to double can lose precision, while keeping the magnitude.
Explicit conversions go from larger to smaller types, or between types that are not directly compatible. They can lose data, as when a cast drops the decimal part of a double. In a checked context they can also throw an OverflowException.
The Convert class handles conversions a cast cannot do, like turning the string "123" into an int.
// Implicit conversion
int intValue = 123;
double doubleValue = intValue; // Automatic conversion
// Explicit conversion
double largeValue = 123.456;
int smallValue = (int)largeValue; // Manual cast, loses decimal part
// Using Convert class
string numberString = "123";
int convertedValue = Convert.ToInt32(numberString);
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓