readonly List as a property, how can I achieve this?

  • Thread starter Thread starter ThunderMusic
  • Start date Start date
T

ThunderMusic

Hi,
I have the following :

private List<int> _myList = new List<int>();
public List<int> myList
{
get { return _myList; }
}

What I want is that the user cannot modify the content of the list, it can
only see what's in it. Is it something I can do or will I have to implement
my own collection class based on List<>?

thanks

ThunderMusic
 
Would a collection suit your purpose? If so, have a look at this generic
collection class:
System.Collections.ObjectModel.ReadOnlyCollection(Of T)

HTH ...
 
thanks a lot... exactly what I needed...

Emby said:
Would a collection suit your purpose? If so, have a look at this generic
collection class:
System.Collections.ObjectModel.ReadOnlyCollection(Of T)

HTH ...
 
Back
Top