Comment Re:Getting screwed in both directions (Score 1) 443
Well it came up in some port code from another language so it defiantly isn't an every day occurrence.
The problem is if you store some opaque data as say an object reference. Then make explicit cast accessors to get at the object as some value type. If you then call a mutator on the valuetype, you change a temporary version that was made for the cast instead of the underlying object.
Regardless porting c++ to c# is rife with all sorts of nice gems. Properties have the same issue in this specific case.
The problem is if you store some opaque data as say an object reference. Then make explicit cast accessors to get at the object as some value type. If you then call a mutator on the valuetype, you change a temporary version that was made for the cast instead of the underlying object.
Regardless porting c++ to c# is rife with all sorts of nice gems. Properties have the same issue in this specific case.