C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

plzzzzzzzz help me


Posted Date: 11 Jun 2007      Posted By: swathi.chilumula      Member Level: Gold     Points: 2   Responses: 8



What are hash tables????????
what is the pupose of hash tables and where we have to use these???





Responses

Author: Abhishek Arya    11 Jun 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

you can use kb in dotnetspider about hash tables

http://www.dotnetspider.com/qa/Question49436.aspx



Author: Durga Prasad    11 Jun 2007Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

this url will help u
http://www.sparknotes.com/cs/searching/hashtables/section1.html



Author: Shiva SaiRam    11 Jun 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hashtable is useful when you need to store data in a key and value pair.

private Hashtable hshTable = new Hashtable();

Adding Items to a Hashtable

Add method of Hashtable is used to add items to the hashtable. The method has index and value parameters. The following code adds three items to hashtable.

hshTable .Add("Author1", "Shiva");
hshTable .Add("Author2", "Sai");
hshTable .Add("Author3", "Ram");

Retrieving an Item Value from Hashtable:

The following code returns the value of "Author1" key:

string strAuthor1 = hshTable["Author1"].ToString();

Removing Items from a Hashtable

The Remove method removes an item from a Hashtable. The following code removes item with index "Author1" from the hashtable:

hshTable.Remove("Author1");

Looking through all Items of a Hashtable

The following code loops through all items of a hashtable and reads the values.

// Loop through all items of a Hashtable
IDictionaryEnumerator enumVar = hshTable.GetEnumerator();
while (enumVar.MoveNext())
{
Response.Write(enumVar.Value.ToString() + " " );
}



Author: sundarakshi    11 Jun 2007Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

A Hashtable is collection of values are stored with key,value.

(Eg)
Hashtable h = new Hashtable();
h.Add("Key1", "Value1");
h.Add("Key2", "Value2");
h.Add("Key3", "Value3");
h.Add("Key4", "Value4");
h.Add("Key5", "Value5");

Getting Value From Hashtable
Console.WriteLine(h.Item("Key3"));

By Issusing the key we can get the values


Regards
Somu
somushan@yahoo.com



Author: ChandraShekar Thota    11 Jun 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

view state data can be stored in hash table

Chandra Shekar Thota
Microsoft MVP
DNS is Y(Our) Site.Please work more on it to make it Worlds Best Technical Site
chandrashekarthota@gmail.com



Author: ChandraShekar Thota    11 Jun 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

we can store values in key value pairs

Chandra Shekar Thota
Microsoft MVP
DNS is Y(Our) Site.Please work more on it to make it Worlds Best Technical Site
chandrashekarthota@gmail.com



Author: ChandraShekar Thota    11 Jun 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

private Hashtable hshTable = new Hashtable();

Adding Items to a Hashtable

Add method of Hashtable is used to add items to the hashtable. The method has index and value parameters. The following code adds three items to hashtable.

hshTable .Add("Author1", "Shiva");
hshTable .Add("Author2", "Sai");
hshTable .Add("Author3", "Ram");

Chandra Shekar Thota
Microsoft MVP
DNS is Y(Our) Site.Please work more on it to make it Worlds Best Technical Site
chandrashekarthota@gmail.com



Author: Altaf Hussain    11 Jun 2007Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi

The hashtable will be faster comparing to array, because hashtable retrives the record randomly,
It means the objects may not come out from the HashTable in the same order as you put them in.

eg

private Hashtable htable = new Hashtable();

htable.Add("one","Yahoo");
htable.Add("Two","Google");
htable.Add("three","orkut");
htable.Add("four","Naukri");



IDictionaryEnumerator enumVar = htable.GetEnumerator();
while (enumVar.MoveNext())
{
MessageBox.Show(enumVar.Value.ToString() + " " );
}

output

1 orkut
2 Naukri
3 Google
4 Yahoo

the purpose may be retrieve faster,



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Image Store and Retrieval
Previous : Input Outparameter in Sqlserver
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use