top of page

Basic collections - C#

Welcome in last material before first program!

This topic will be about collections almost the most important things like all. :D I will talk just for a while, I know it will be just a begging and it is totally basics containers not all standard containers.

Containers can be one or more dimensional - simple example:

one dimensional (1x5) [1,2,3,4,5]

two dimensional (3x5)

[1,2,3,4,5]

[6,7,8,9,10]

[11,12,13,14,0]

ArrayList - is the most basic container without many function implemented. It is kind of dynamic table, plus is that you can fast take element from known place, but deleting from the middle can be slow, especially when you have many elements.

List list1 = new ArrayList();

List list2 = new ArrayList(16);

As also functions like add, remove at x, length etc. Everything is in the packet for collection and you don't need to implement it.

Dictionary - is casual collection with key and value. The values are sorted by key value.

HashTable - Hash table is kind of array with value and key, but key - need to be unique.

SortedList - It is kind of dynamic table - list with order. Key need to be unique.

Stack - Kind of queue with last element is first when you want to take it out. You can imagine books which you want to segregate - firstly you put all on heap. Next you want to order all on shelf, so you took last book as first. After all first book on heap is last which you put to the shelf.

As also functions like push (add), pop (get), length etc. Push and pop are add and remove, but in queues.

Queue - it is simple idea, like in shop - who was first he can pay first and leave shop. The same idea is in queues. If you want to take some from it you will take the first element which you put there.

BitArray - kind of array to collecting bits, not interesting for beginners.

Of course you can implement more containers using interfaces, but this you can use at the beginning of your programming journey. The most important containers are here, so try to use them in yours applications.

Subscribe me!

Be sure that you read all.

  • Facebook Clean
  • Black Twitter Icon
  • Black Instagram Icon
  • Black YouTube Icon
Recent Posts
bottom of page