A
Allan Ebdrup
I have a dictionary that I would like to load with data and then have as
read only, so I can pass it as a result of a get on a property and not have
the recipient of the dictionary change the data in it (and change the data
for everyone else using the property).
I can see from:
http://msdn.microsoft.com/library/d...nref/html/cpconconstructorusageguidelines.asp
that you should use a method when:
"The member returns an array. Properties that return arrays can be very
misleading. Usually it is necessary to return a copy of the internal array
so that the user cannot change internal state."
But I don't want to have to copy my dictionary, I just don't want the reader
of the dictionary to be able to change the data in it.
What's the best solution?
read only, so I can pass it as a result of a get on a property and not have
the recipient of the dictionary change the data in it (and change the data
for everyone else using the property).
I can see from:
http://msdn.microsoft.com/library/d...nref/html/cpconconstructorusageguidelines.asp
that you should use a method when:
"The member returns an array. Properties that return arrays can be very
misleading. Usually it is necessary to return a copy of the internal array
so that the user cannot change internal state."
But I don't want to have to copy my dictionary, I just don't want the reader
of the dictionary to be able to change the data in it.
What's the best solution?