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
热门推荐
3 祝福语简短古诗词
5 贫困户祝福语简短
10 他舅生日祝福语简短
11 结婚祝福语粤语大全简短
12 给侄子祝福语简短精辟
13 送外卖祝福语大全简短
14 同事男生节祝福语简短
15 形容新年的祝福语简短
16 简短的小孩春节祝福语
17 农民朋友发财祝福语简短
18 新年祝福语短句简短搞笑