Wednesday, January 17, 2007

How to get around Array Limitations

If you are a C# programmer, you have most likely used an Array at some point. You will probably find that Arrays have many limitations, mainly that once they are created, their size is fixed, and you can't add objects to it without creating a new array. So how do we get around this?

Collections; Like arrays, collections enable you to maintain groups of objects, but unlike arrays collections can include more advanced functionality, such as controlling access to the objects they contain, searching and sorting, etc.
Arrays are implemented as an instance of the System.Array class and are just on type of what are known as collection classes. Much of the functionality of a collection comes through implementing interfaces from the System.Collections namespace, thus standardizing collection syntax.

Since the collection functionality is available through interfaces you aren't limited to using basic collection clases such as System.Array. Instead, you can create your own customized collection classes.

1 Comments:

Anonymous Anonymous said...

Great post! Sounds so professional. I also found ArrayList. Which basically allow one to create an array of an unspecified size. One could then add items as necessary. Thanks for the write up of collections though.

11:09 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home