C#中Hashtable类的Values属性是什么?
Values属性获取一个ICollection,其中包含Hashtable中的值。
声明哈希表集合-
Hashtable ht = new Hashtable();
现在添加值
ht.Add("One", "Henry");
ht.Add("Two", "Kevin");
ht.Add("Three", "David");要显示Hashtable中的值,以下是代码-
示例
using System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
Hashtable ht = new Hashtable();
ht.Add("One", "Henry");
ht.Add("Two", "Kevin");
ht.Add("Three", "David");
//显示值
foreach (string value in ht.Values) {
Console.WriteLine(value);
}
Console.ReadKey();
}
}
}输出结果
David Henry Kevin
热门推荐
10 最新高考祝福语 简短
11 国庆中秋祝福语大全简短
12 生日奶茶红包祝福语简短
13 家庭生日祝福语大全简短
14 生日祝福语宿舍舍友 简短
15 春节新年祝福语简短幽默
16 女士简短祝福语大全集
17 简短元宵节祝福语
18 老爸的祝福语简短独特