ex-09-19
来自「Programming Csharp Source Code(代码) Prog」· 代码 · 共 41 行
TXT
41 行
// Example 09-19: Using the IDictionaryEnumerator interface
namespace Programming_CSharp
{
using System;
using System.Collections;
// a simple class to store in the array
public class Tester
{
static void Main()
{
// Create and initialize a new Hashtable.
Hashtable hashTable = new Hashtable();
hashTable.Add("000440312", "George Washington");
hashTable.Add("000123933", "Abraham Lincoln");
hashTable.Add("000145938", "John Galt");
hashTable.Add("000773394", "Ayn Rand");
// Display the properties and values of the Hashtable.
Console.WriteLine( "hashTable" );
Console.WriteLine( " Count: {0}", hashTable.Count );
Console.WriteLine( " Keys and Values:" );
PrintKeysAndValues( hashTable );
}
public static void PrintKeysAndValues( Hashtable table )
{
IDictionaryEnumerator enumerator = table.GetEnumerator();
while ( enumerator.MoveNext() )
Console.WriteLine( "\t{0}:\t{1}",
enumerator.Key, enumerator.Value );
Console.WriteLine();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?