I have code below:
class Program
{
private static void Main()
{
object obj = 1;
Console.WriteLine(Convert.ToDouble(obj)); // why OK without exception?
var d = (double) obj; // why exception?
}
}
The "Convert.ToDouble(obj)" works to convert from int to double, but "var d=(double) obj" will throw exception. Why is such a difference? What's the difference between these 2 types of conversions?