Can someone tell me why the line with "//Compiles" compiles, and why the line with "//Doesn't Compile" does not?
I don't understand why A would be implicitly convertible to B, not the other way round.
public class SomeClass {
static public void Test() {
AClass a = new AClass();
BClass b = new BClass();
a = b; // Compiles
b = a; // Doesn't compile
}
}
public class AClass {
public void AMethod() {
Console.WriteLine("AMethod");
}
}
public class BClass : AClass {
public void BMethod() {
Console.WriteLine("BMethod");
}
}
thanks!