Thanks for your reply and I understand and accept what you say.
To answer the questions asked by the other contributers before Xmas:
This is what prompted the question. In C++ structures and classes are very
similar in both syntax and semantics. Assignment of structures assigns the
values of the data members, and the same applies to classes. In C++, if A
and B are classes then A=B does not make A an alias of B - subsequent
changes to B have no effect on A. But in C# A does become an alias of B
i.e. subsequent changes to B also change A.
No, subsequent changes to B itself don't change A in the slightest.
Subsequent changes to the object B's value refers to will be visible
through the reference value of A, but that's just the same as using
pointers in C++.
So in C#, unlike C++, the
assignment operator operates very differently if A and B are classes to the
way it operates if A and B are structures.
No it doesn't. It doesn't behave differently at all. It assigns the
value of the expression to the variable. The difference in C++ is that
the value of a variable can be an object - that's not possible in C#.
Values of variables can only either be null, a reference, or a value
type.
Although I accept Jon's explanation I do retain a slight reservation in that
in C# we have reference types and value types and suggest that it can be
confusing to mix the terminology and talk about the "value" of reference
types.
On the contrary - it's more confusing to talk about "aliasing" A and B
when the variables themselves are entirely unrelated except they happen
to have the same value. What's important is that the value is a
reference. Using the terminology that the value of a variable can be a
reference is accurate and is what is used throughout proper
documentation. Furthermore, it makes parameter passing simple to
explain.
Once you understand the difference between a variable and the object it
refers to, it's all very simple. There's only one type of assignment to
understand, garbage collection is understandable, etc. Changing the
assignment operator would be an awful substitute for understanding what
reference types are, IMO.