This statement is not true. (This a "politically correct" expression though. :-))
There is no such thing as "instance overwriting the instance", actually. It's either the same instance or not. There is nothing in your code which would cause any cross-modification, and there is no static code. So, I must conclude, no "overwriting" takes place. It's just your "experiment" is invalid, or your observations, but you did not provide any information.
I seriously suspect you don't understand something very, very, very basic. Do you really understand that the class is the
reference type and not a
value type? The variable are not "copied" by assignment but reference the same object. Consider:
Node first = new Node();
Node second = new Node();
second.Kova1 = 1;
second = first;
second.Kova2 = 2;
Please, get back to the very basics.
Also, some problems with the code:
The constructor
public Node() {}
is not needed at all.
The
public
declarations may not be needed. If you are going to use some types of members in the same assembly, they should better be
internal
. This is the same as
public
, only for the same assembly. You should not allow more access than this is really needed.
In most cases, the
public
or
internal
type fields means bad style. For better code maintainability, make all fields
private
and expose them only throw properties. The properties can have any access modifiers. At first, turn all fields into auto-backed properties, so later you will get an opportunity to write some specific getters or setters for them.
Good luck,
—SA