Tuesday 11 March 2014

Collections in C#

Collection class:-

Collection classes are pre-define class to collect the data specialize manner.collection class are same or different interface.This is data structure in C#. All belong to "System.Collections"namespace.In its simplest form, an object has a unique value. In its more complex form, which contains references to many other objects. . NET Framework provides the collections:


 ArrayList:
Then the Array List is a collection that is in System.Collections. Stores objects of any kind. No need to worry about the types of elements. But you have to throw them out when you need to use them. This is inconvenient.

Program that uses ArrayList:

Output

Hash table
Let continue to use Hash table. This is a search data structure that uses a hash code to quickly find items. Dictionary newest collection is often more appropriate for programs when available.


stack :

They are functions push,pop,peek.

Stack push:

Returns the object at the top of the Stack without removing it.
for example:

Output:

Stack pop:

Removes and returns the object at the top of the Stack.



for example:
Output:

Stack peek:

It is just remove first value but not come stack.
Output:




0 comments:

Post a Comment