Basically, I was always in the understanding that you should return the expose base types whenever you can and worry about implementation details internally, which makes sense...
If you look at the code for a read-only collection it does not have an \"Add\" method, but instead defines the ICollection<T>.Add(T Value) method (explicit interface implementation).
开发者_运维技巧The MSDN article doesn\'t really explain this. List<MyObject> FirstList = new List<MyObject>();
ReadOnlyCollection<T> realises the ICollection<T> interface which has methods like Add and Remove. I know how to hide methods from Intellisense using attributes, but how is it possible to
.net class SynchronizedReadOnlyCollection has 4 constructors. public SynchronizedReadOnlyCollection();
I have a class with a collection member. I would like to prevent external code from modifying this collection directly, instead using methods (which can perform the appropriate validation etc).
I ran a security code analyst i found myself having a CA2105 warning. I looked at the grade tampering example. I didn\'t realize you can assign int[] to a readonly int. I thought readonly was like the
I have tried various configurations, but cannot g开发者_JAVA百科et it working. I am wondering if it is supported?I\'ll assume that the answer is no!