Variable length arrays in .NET 2.0?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have not kept up on the changes to .NET 2.0. Besides ArrayList are there
any other array's or containers that can have an adjustble size? With
Generics is there a container that I can Add items to of a known type and
have the array or container adjust to hold it?

Thank you.

Kevin
 
"Kevin Burton" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...

|I have not kept up on the changes to .NET 2.0. Besides ArrayList are there
| any other array's or containers that can have an adjustble size? With
| Generics is there a container that I can Add items to of a known type and
| have the array or container adjust to hold it?

Try List<T>, Dictionary<K, V>, etc for starters.

Joanna
 
Kevin Burton said:
I have not kept up on the changes to .NET 2.0. Besides ArrayList are there
any other array's or containers that can have an adjustble size? With
Generics is there a container that I can Add items to of a known type and
have the array or container adjust to hold it?

You're looking for List<>.

List<string> myList = new List<string>();
myList.Add("Hello");
myList.Add(" ");
myList.Add("World");

This can then be converted to an array, or iterated over using standard
syntax.
 
Back
Top