|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
readonly List as a property, how can I achieve this?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 ... Show quote "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message news:e6GyETKwGHA.5056@TK2MSFTNGP06.phx.gbl... > 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 > thanks a lot... exactly what I needed...
Show quote "Emby" <e***@blaisesoft-xxx.com> wrote in message news:OkHZKtNwGHA.4756@TK2MSFTNGP02.phx.gbl... > Would a collection suit your purpose? If so, have a look at this generic > collection class: > System.Collections.ObjectModel.ReadOnlyCollection(Of T) > > HTH ... > > "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message > news:e6GyETKwGHA.5056@TK2MSFTNGP06.phx.gbl... >> 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 >> > > |
|||||||||||||||||||||||