Non settable lenght -- it's just the way a collection works.
You can always use an array (string[] stringArr)
Or implement your own collection that inherits from collectionbase and only
allows X elements to be added:
using System.Collections;
public myCollection : CollectionBase
{
private const MAXLENGTH = 50
public Add(srting newItem)
{
if(this.List.Count = MAXLENGTH)
thorw (new Exception("List maxlength encountered")
else
this.List.Add(newItem)
}
}
cheers,
mortb
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:kD*****************@news4.e.nsc.no...
Hi.
I want to know why it is not possible to specify (or determine) the
capacity for a System.Collections.Specialized.StringCollection.
I guess the StringCollection would be the better choice over an
System.Collections.ArrayList
when there is only System.String instances to be stored in it.
The StringCollection provides only one undocumented constructur.
Thank you.