I'm quite new to c# programming. So lets assume we have two assemblies Asm1, Asm2 in which two classes are defined as Follows:
//Asm1
namespace ClassLibrary1
{
public class A//: B
{
B b = new B { i = 2};
public int MyProperty { get { return b.i; } }
}
}
//Asm2
namespace ClassLibrary2
{
public class B
{
public int i;
}
}
Asm1 references Asm2 Now we have a runnable assembly say,asm3, that uses Asm1 with following piece of code:
//Asm3
A a = new A();
System.Console.Write(a.MyProperty.ToString());
the above codes compiles right with no error.
But things go wrong when we make little change in class A and have it inherited from class B. In this case line: A a = new A(); doesn't compile and produces error. But when we add asm2 as a reference to asm3 it works. please tell me why is that. why do an assembly ,with no direct dependency to another assembly, have to reference it? thanks in advance.