Essential C# Casting  Suggest an edit

Implicit Casting

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;

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 object.


Table Of Contents
22 Enum
37 Casting
107 Stream
108 Timers
  ↑ ↓ to navigate     ↵ to select     Esc to close