Hello,
i'm new to C# and I try to create class library. Everything looked fine
till the moment I started to use instance of some class like a property
of another class.
Example:
There's class ClassA with public props int A, int B. Also I have class
ClassB with public props int C, int D, ClassA clsA.
I create one object per each class like this:
MyNamespace.ClassA objClassA = new MyNamespace.ClassA();
MyNamespace.ClassB objClassB = new MyNamespace.ClassB();
objClassB have public property objClassB.clsA. When I set
value to objClassA.A to 2 I see the same value in objClassB.clsA.A.
Why that is? How so?
It seems that i work with references, not with instances.
ClassB has constuctor where clsA is created using code
MyNamespace.ClassA clsA = new MyNamespace.ClassA()
so I thought it is new instance of class ClassA.
Can anybody help me what to do or explain me wha that is?
Thanx a lot, Bedny