📄 ex-09-18
字号:
// Example 09-18: Keys and Values collections
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");
// get the keys from the hashTable
ICollection keys = hashTable.Keys;
// get the values
ICollection values = hashTable.Values;
// iterate over the keys ICollection
foreach(string key in keys)
{
Console.WriteLine("{0} ", key);
}
// iterate over the values collection
foreach (string val in values)
{
Console.WriteLine("{0} ", val);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -