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" );
}
Thursday, September 10, 2009
New Features of Visual Studio 2008 for .NET Professionals
- LINQ Support
- Expression Blend Support
- Windows Presentation Foundation
- VS 2008 Multi-Targeting Support
- AJAX support for ASP.NET
- JavaScript Debugging Support
- Nested Master Page Support
- LINQ Intellisense and Javascript Intellisense support for silverlight applications .
- Organize Imports or Usings .
- Visual Studio 2008 Split View .
- HTML JavaScript warnings, not as errors .
- In built Silverlight Library .
- Visual Studio LINQ Designer.
Subscribe to:
Posts (Atom)