📄 ex-09-19
字号:
// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -