Please consider this scenario:
public class TestType
{
public string a
{
get;
set;
}
public string b
{
get;
set;
}
public override string ToString()
{
return string.Format("a: \"{0}\"\tb:\"{1}\"", a, b);
}
}
TestType class is compiled in a class library, then I use it in this simple program:
static void Main(string[] args)
{
TestType tP = new TestType();
tP.a = "a";
tP.b = "b";
Console.WriteLine(tP.ToString());
Console.ReadKey(true);
}
Obviously it works(correct execution without errors).
Output: a: "a" b:"b"
Then I edit the class in the library like this:
public class TestType
{
public string a
{
get;
set;
}
public string b
{
get;
set;
}
public string c
{
get;
set;
}
public override string ToString()
{
return string.Format("a: \"{0}\"\tb:\"{1}\"\tc:\"{2}\"", a, b, c);
}
}
I recompile just the library and re-run the program (without recompiling it). Now I expected a crash by the program, because it isn't aware of the changes on the class, but it works.
Output: a: "a" b:"b" c:""
How can it work if the type is different from the one it knows?