Implicit Casting

long y = x;    // implicitly converted, no data is lost

Derived d = new Derived(); 
Base b = d;   // Always OK.

Explicit Casting

double  x = 1234.56;
int y = (int) x ;    // y = 1234,  explicitly casted, data lost

Animal x = new Animal(); 
Cat y = (Cat) x;

To avoid exception: use is & as operator

is

if (myObject is Foo)
{
    // casting
}

as

Derived d = new Derived();
Base b = d as Base;

var x = "Hassan";
var y = x as object;

Conversion by Helper Class

Convert.ToInt32(Console.ReadLine());

// try/parse
var intAsString = "10";
var intVal = 0;
Int32.TryParse(intAsString, out intVal);
Console.WriteLine(intVal);