6 June 2011

Collections in Dotnet Framework

Collections in Dotnet Framework

Why Use Collections in dotnet?


-Individual elements serve similar purposes and are of equal importance.
-The number of elements is unknown or is not fixed at compile time.
-You need to support iteration over all elements.
-You need to support sorting of the elements.
-You need to expose the elements from a library where a consumer will expect a collection type.

Collections can vary, depending on how the elements are stored, how they are sorted, how searches are performed, and how comparisons are made. The Queue class and the Queue generic class provide first-in-first-out lists, while the Stack class and the Stack generic class provide last-in-first-out lists. TheSortedList class and the SortedList generic class provide sorted versions of the Hashtable class and the Dictionary generic class. The elements of a Hashtable or a Dictionary are accessible only by the key of the element, but the elements of a SortedList or a KeyedCollection are accessible either by the key or by the index of the element. The indexes in all collections are zero-based, except Array, which allows arrays that are not zero-based.

9 comments:

  1. Thanks. I would like to know about Lists and Collections? When to use lists and when to use collections?

    http://www.tanmayonrun.blogspot.com

    ReplyDelete
  2. 1.In arrays you can't dynamically add elements when ever you need with out define the size of array, but when using collection it is possible
    2.List is one type of collections for more information see this

    http://msdn.microsoft.com/en-us/library/ms172181(v=vs.80).aspx

    ReplyDelete
  3. It helped me. Thanks. But dada, another question. Take a look at the following code.
    _______________

    anyFunction()
    {
    Dim s,t,d As Integer

    ....some code

    }
    _______________

    Now my question is that will this function allocate memory for s,t,d each time I call the function or it will create them only once? I mean, as "Dim" allocates memory, will it allocate each time?

    If so, then will I have to Dispose each variable after operation?

    ReplyDelete
  4. when ever you call the function, each time memory is allocated for the variable, you no need to dispose the variable because dotnet have automatic garbage collector and it dispose it automatically

    ReplyDelete
  5. Thanks Dada. I was confused with that.

    I hope you will help me with another suggestion. What is a factor to get a job in Software Company, RESULT or MY WORKS? Because, you know, if I keep reading to get a better marks in exam, I can't give time to develop anything. Like, I learned the algorithm of postfix notation and after that it took me about 3 weeks to build up a complete calculator which calculates expressions. After that the final exam came and I got A- in the course of data structure. Now which will take effect in the job interview, my implementation of the algorithm or the result of that course?

    ReplyDelete
  6. As a student , Mark is the only fact that prove your knowledge as per our stupid exam system,
    study the basics strongly, give 65% for marks and 35% for your works, If you got more marks your
    parents was happy,break campus interview eligibility criteria etc. Then choose your specilization now itself

    ReplyDelete
  7. Thanks dada. But the problem is that, once get me with a problem to solve or a job to be done, I forget everything else. There were some big mistakes I have done while I was in class 9 to class 12, which has spoiled my everything, thats why I am trying a lot to stand up again.

    I wish I could have become a programmer.

    :: In your blog photo, you looks like 'Farhan Qureshi' of the film '3 Idiots'. I forgot to say, I am from Bangladesh, but I think you have already found it from my profile.

    ReplyDelete
  8. Cool,Every thing will go fine..

    Thanks for your comments....

    Ya i see your blog...thats good attempt....

    ReplyDelete
  9. This comment has been removed by a blog administrator.

    ReplyDelete

Comments Welcome

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...