M
Matthias S.
Hi,
I have a class (say Company) which should expose a ReadOnlyCollection
property (say EmployeesCol) hosting userdefined types (Employee).
Since only the internals of the Company class should be allowed to
modify the EmployeesCol, I'd like to expose a read only collection as a
property, so that the users of my Company class can enumerate the
employes, but can't add or remove those.
I think this can be done using the ReadOnlyCollection<T> generic, but I
don't seem to understand the way of using this properly. Do I have to
derive from ReadOnlyCollection<T> or can I just use it in a property
declaration.
It would be nice if somebody could help me getting startet on this one.
Thanks in advance,
Matthias
I have a class (say Company) which should expose a ReadOnlyCollection
property (say EmployeesCol) hosting userdefined types (Employee).
Since only the internals of the Company class should be allowed to
modify the EmployeesCol, I'd like to expose a read only collection as a
property, so that the users of my Company class can enumerate the
employes, but can't add or remove those.
I think this can be done using the ReadOnlyCollection<T> generic, but I
don't seem to understand the way of using this properly. Do I have to
derive from ReadOnlyCollection<T> or can I just use it in a property
declaration.
It would be nice if somebody could help me getting startet on this one.
Thanks in advance,
Matthias