A value will automatically be cast to the appropriate type if the compiler knows that it can always be converted to that type.
int number = -1; object value = number; Console.WriteLine(value);
In this example, we didn’t need to use the typical explicit casting syntax because the compiler knows all
ints can be cast to
objects. In fact, we could avoid creating variables and pass
-1 directly as the argument of
Console.WriteLine() that expects an