You have these classes shown below:
public class A
{
}
public class B : A
{
}
You cast the base class to a type of the derived class
A w = (B) new A();
B x = (B) new A();
This will not work on the run time because you cannot really convert a base class to a derived class.
But why is there no compile time error
? why does visual studio allowed me to reach run-time before throwing the error?