1

what do means mutable and immutable values in .net?

In msdn: https://msdn.microsoft.com/en-us/library/ms229031%28v=vs.110%29.aspx

Struct Design

X DO NOT define mutable value types.

microsoft says when a property getter returns a value type, the caller receives a copy. Because the copy is created implicitly, developers might not be aware that they are mutating the copy, and not the original value. But the Point and Size structures has public read/writable properties. so it is good practice to write structs with properties? properties in a struct should be readonly, writeonly, or no matter? what other immutable values exists?

Meska
  • 85
  • 1
  • 10
  • 1
    Point and Size are a great example of [MS breaking their own guidelines for the sake of performance](http://stackoverflow.com/a/14192612/14357). There's plenty of question/answers to explain this... [Here's a good one](http://stackoverflow.com/questions/441309/why-are-mutable-structs-evil). – spender Nov 08 '15 at 18:14

0 Answers0