A common problem in this situation is immutability. When byte [] is returned, the caller can change it without going through your setter. Think about what happens if someone does
byte[] retVal = MyInstance.FileRawData; retVal[1] = 0x00;
Probably not what you want at all, because the value has changed inside MyInstance, which can cause problems. Therefore, to stop the cloning of the array, but it can be potentially time-consuming, and properties should not be used for lengthy operations. The best way to solve this is to switch to methods for sets and get if the array will always be tiny. Of course, when you start writing GetFileRawData () as the name of a method, FXCop will tell you that this should be a property, you cannot win a grin. In this case, just disable it in the code; for this one method.
source share