Monday, 11 July 2016

Collection Classes : System.Collection

Collection classes are specialized classes for data storage and retrieval. These classes provide support for stacks, queues, lists, and hash tables. Most collection classes implement the same interfaces.

ArrayList-
hash table - 
SortedList- 
Stack
Queue
BitArray- 
dictionary -

There are two ways to group objects  by
1. creating arrays of objects,

2.  creating collections of objects.

A collection is a class, so you must declare an instance of the class before you can add elements to that collection.

********************the System.Collections.Generic namespace********************
system.collections.Generic - name space for list or same types of variable used for the collections 
Using a Simple Collection

##
generic List<T>

The following example creates a list of strings and then iterates through the strings by using a or foreach statement.

var salmons = new List<string>();
salmons.Add("chinook");
salmons.Add("coho");
salmons.Add("pink");
salmons.Add("sockeye");

// Iterate through the list.
foreach (var salmon in salmons)
{
    Console.Write(salmon + " ");
}

No comments:

Post a Comment