Answer to Question #54345 in C# for keivan

Question #54345
I want to have a simple code that demonstrtes hasch table and its concept.
1
Expert's answer
2015-09-01T00:49:41-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
/*

Hashtable class is designed to create a collection in which to store its elements is a hash table.
* Information is stored in a hash table by using a mechanism called hashing.
* When hashing to determine the unique value called a hash code, using the information content of a special key.
* Summarized hash code serves as an index into a table in which desired data stored corresponding to the specified key.
* Converting a key in the hash code is executed automatically,
* and therefore it is the hash code is not available to the user at all. The advantage of hashing is that it provides a constant-time search operations, retrieving and setting values ​​irrespective of the magnitude data arrays.



*/
namespace HashExample
{
class Program
{
static void Main(string[] args)
{
// Create a hash table
Hashtable htexample = new Hashtable();

// Добавим несколько записей
htexample.Add("BillGates5", "123bg");
htexample.Add("ElonMAsk", "345em");
htexample.Add("SteveJobs", "678SJ");

// We consider the collection of keys
ICollection keys = htexample.Keys;

foreach (string s in keys)
Console.WriteLine(s + ": " + htexample[s]);

Console.ReadLine();

}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS