Thursday, September 10, 2009

Hashtable

Creating a Hashtable :
ref:http://en.csharp-online.net/Hashtable_class
http://www.c-sharpcorner.com/UploadFile/mahesh/Hashtable11082005171748PM/Hashtable.aspx


The Hashtable class in C# represents a hashtable.

private Hashtable hshTable = new Hashtable();

Adding Items to a Hashtable :

hshTable .Add("Author1", "Mahesh Chand");
hshTable .Add("Author2", "James Brand");
hshTable .Add("Author3", "Mike Gold");

Retrieving an Item Value from Hashtable:

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

Removing Items from a 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 HashtableIDictionaryEnumerator en = hshTable.GetEnumerator();
while (en.MoveNext())
{
string str = en.Value.ToString();
}

Using The Default Item Property To Change Its Corresponding Key

// The default Item property can be used to change the value associated with a key.
exampleTable[ "rtf" ] = "winword.exe";
// If a key does not exist, setting the default Item property
// for that key adds a new key/value pair.
exampleTable[ "doc" ] = "winword.exe";

//ContainsKey can be used to test keys before inserting them.
if( !exampleTable.ContainsKey( "ht" ) )
{
exampleTable.Add( "ht", "hypertrm.exe" );
}

New Features of Visual Studio 2008 for .NET Professionals

  1. LINQ Support
  2. Expression Blend Support
  3. Windows Presentation Foundation
  4. VS 2008 Multi-Targeting Support
  5. AJAX support for ASP.NET
  6. JavaScript Debugging Support
  7. Nested Master Page Support
  8. LINQ Intellisense and Javascript Intellisense support for silverlight applications .
  9. Organize Imports or Usings .
  10. Visual Studio 2008 Split View .
  11. HTML JavaScript warnings, not as errors .
  12. In built Silverlight Library .
  13. Visual Studio LINQ Designer.