Don't expose your generic list used in classes

If you expose a generic list outside you class there will be a desing warning ( by FxCop ) indicating that generic list are not designed to expose them outside the class.

Reasons for that are:

- The generic list is designed for performance and with that there is no logic build in the preserve state over inherited classes or different threads.

- The methods on the list are exposed as well. If the originated class is designed for to maintain the state of the list the methods must be public available.

Solution is not the use the Generic.Collection.List<t> but the Collections.ObjectModel.Collection<T> or Collections.ObjectModel.ReadOnlyCollection<T> or Collections.ObjectModel.KeyedCollection<TKey, TItem>

Which are, strange enough, not in the same namespace.
Allso strange is that FxCop doesn't generate the warning if you expose the list as a ienumerable with the AsEnumerable() method.
This ienumerable can be cast back to a generic list and the methods are available and the data can be mutated again.

 So my opinion is if you want to expose mutable list just use Ienumerable and otherwise use ReadOnlyCollection.

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!