C# 中 Hashtable 类的 Values 属性是什么?
Values 属性获取一个包含 Hashtable 中值集合的 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");
// Displaying values
foreach (string value in ht.Values) {
Console.WriteLine(value);
}
Console.ReadKey();
}
}
}输出
David Henry Kevin
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP