Home All Groups Group Topic Archive Search About

Variable length arrays in .NET 2.0?

Author
16 Sep 2006 6:32 PM
Kevin Burton
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

Author
16 Sep 2006 7:19 PM
Joanna Carter [TeamB]
"Kevin Burton" <KevinBur***@discussions.microsoft.com> a écrit dans le
message de news: C24DB59A-7690-4BC2-BE00-11AC76CF3***@microsoft.com...

|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

--
Joanna Carter [TeamB]
Consultant Software Engineer
Author
16 Sep 2006 8:36 PM
Chris Mullins
"Kevin Burton" <KevinBur***@discussions.microsoft.com> wrote

>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.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins

AddThis Social Bookmark Button