Hi Mario,
I don't think the rules for structs and classes are the same.
My C# book (a bit old) says structs are "value" types like integers, so they live on the stack.
Classes are "reference" types and live on the heap.
So I think when you did a = b = new A (X = 3, Y= 5);
I believe you created b, and then copied it into a.
a and b then do not point/reference the same memory anymore.
Try again with a class, instead of a struct and check that the behaviour then works as expected.
Paul - about to drive to the rubbish tip with a car full of mud and grass!
Paul, many thanks for your comment, but...that's exactly what I mean!
The original post's bottom results are for the regular .Net framework, and they're correct at all. A struct is always copied entirely, whereas a class is just referenced with "pointers" (just to understand).
If you re-check the Netduino results (right below the snippet) are contradictory.
First off, the "multiple assignment" (or whatever is called) seems creating a class instead of a struct, then "a" and "b" are referring to the same memory area. That is, when you alter "a", also "b" looks altered. That's a clear clue that the objects are *not* two, but just one.
Secondly, when I assign "c" from "a" (even before altering "a") the copy looks working fine. The subsequent "a" modification does not alter "c". That's the right way on how the structs should behave.
Thirdly, any object should yield "true" when compared to itself.
The fourth maybe could be comprehensible, although this is the very first time I noticed it. In the regular .Net you can compare two structs (same type) by simply calling "Equals", without any need to override that method (unless for performance). However it seems that the MS FxCop rules strongly suggests to override and define your own comparison function, because the default implementation leverages the reflection. In this case I may understand that it should be overridden.
I may also be in wrong, but the same snippet running on PC evidences the anomaly!
Good luck with your car! I refuse to wash it, because the day later is dirty again...
Biggest fault of Netduino? It runs by electricity.