HashTable 元素的查找
2024-08-25 02:22:20
Hashtable 特点:键与值成对存在,键是唯一的,不能重复。在查找元素的时候,我们往往是依据键区查找值的
三种方法
contains 包含
containsKey
containsValue
通常我们只用containsKey方法
class Program
{
static void Main(string[] args)
{
Hashtable ht = new Hashtable();
ht.Add(, "张三");
ht.Add(, "张四");
ht.Add(, "李三");
ht.Add(, "王三");
ht.Add(, "刘三");
ht.Add(, "孙三");
foreach (DictionaryEntry item in ht)
{
Console.WriteLine("键{0},值{1}",item.Key,item.Value);
} if (ht.ContainsKey())
{
Console.WriteLine("存在");
}
else
{
Console.WriteLine("不存在");
}
Console.Read();
}
最新文章
- DigitalOcean 建站笔记
- ZEALER背后的乐视云视频
- 让你的PHP更安全之PHP.ini
- UDP socket 设置为的非阻塞模式
- C#局域网桌面共享软件制作(二)
- Linux系统管理员应该了解的一些I/O统计工具
- 新型Web劫持技术
- 深入理解JAVA虚拟机之JVM性能篇---垃圾回收
- python为运维人员打造一个监控脚本
- POJ-1032-拆数字
- symfony简单的博客练习,熟悉具体开发流程
- django的分页与添加图片
- php7 数据导出Excel office 2011中文乱码问题
- C# 委托知识总结
- Linux CentOS Nginx安装配置
- oracle--ORA-00054: 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效
- HDU.5730.Shell Necklace(分治FFT)
- MySQL数据复制到其他主机时报错
- spring结合mockito
- Knockout.js Style绑定