C#基础课程之五集合(HashTable,Dictionary)
HashTable例子:
#region HashTable
#region Add
Hashtable hashTable = new Hashtable();
Hashtable hashTableNews = new Hashtable();
string[] StringArray=new string[];
hashTableNews.Add(, StringArray);
hashTableNews.Add(, );
hashTableNews.Add(,);
Console.WriteLine(hashTableNews.);
object[] Array = new object[];
hashTable.Add(, "第一");
hashTable.Add(, "第二");
hashTable.Add(, "第三");
hashTable.Add(, "第四");
hashTable.Add(, "第五");
hashTable.Add(, "第六");
#endregion
#region Contains
bool ContainsResult = hashTable.Contains();//查找Key值
Console.WriteLine(ContainsResult);
bool ContainsKeysResult = hashTable.ContainsKey();//查找Key值
Console.WriteLine(ContainsKeysResult);
bool ContainsValueResult = hashTable.ContainsValue("第一");//查找Value值
Console.WriteLine(ContainsValueResult);
#endregion
int i = hashTable.Count;
Console.WriteLine(i);
foreach (DictionaryEntry dicEntry in hashTable)
{
Console.WriteLine(" " + dicEntry.Key + " " + dicEntry.Value);
}
foreach (var key in hashTable.Keys)
{
Console.WriteLine(" " + key + " " + hashTable[key]);
}
Hashtable hashTableNew = (Hashtable)hashTable.Clone();//浅表复制,只复制结构 hashTable.CopyTo(Array, );
foreach (var item in Array)
{
Console.WriteLine(" " + item);
}
DictionaryEntry[] Array1 = new DictionaryEntry[];
hashTable.CopyTo(Array1, );
foreach (DictionaryEntry item1 in Array1)
{
Console.WriteLine(" " + item1.Key + " " + item1.Value);
}
#region Equals
Hashtable hashTable1 = new Hashtable();
hashTable1.Add(, "第一");
hashTable1.Add(, "第二");
hashTable1.Add(, "第三");
hashTable1.Add(, "第四");
hashTable1.Add(, "第五");
hashTable1.Add(, "第六");
bool result1 = hashTable.Equals(hashTable1);
Hashtable hashTable2 = new Hashtable();
hashTable2.Add(, "第一");
hashTable2.Add(, "第二");
hashTable2.Add(, "第三");
hashTable2.Add(, "第四");
hashTable2.Add(, "第五");
hashTable2.Add(, "第六");
bool result2 = hashTable.Equals(hashTable2);
Console.WriteLine(result2);
Hashtable hashTable3 = hashTable;
bool result3 = hashTable.Equals(hashTable3);
Console.WriteLine(result3);
#endregion
Console.ReadLine();
hashTable.Remove();
hashTable.Clear(); #endregion
#region Dictionary
Dictionary<string, int> dictionary = new Dictionary<string, int>();
Dictionary<string, string[]> dictionary1 = new Dictionary<string, string[]>();
Dictionary<string, ArrayList> dictionary2 = new Dictionary<string, ArrayList>();
Dictionary<string, emp> dictionary3 = new Dictionary<string, emp>();
Dictionary<string[], int> dictionary4 = new Dictionary<string[], int>();
string[] value = new string[];
value[] = "";
dictionary1.Add("", value);
foreach (var item in dictionary1)
{
Console.WriteLine(" " + item.Key );
foreach (var items in item.Value)
{
Console.WriteLine(" " + items);
}
}
Console.ReadLine();
#endregion
本系列教程:
C#基础总结之八面向对象知识点总结-继承与多态-接口-http://www.cnblogs.com/spring_wang/p/6113531.html
C#基础总结之七面向对象知识点总结1http://www.cnblogs.com/spring_wang/p/6113526.html
C#基础总结之六 DataTable (临时表/数据源) 和Datatable 名片练习http://www.cnblogs.com/spring_wang/p/6113520.html
C#基础总结之五Dictionary<string, string[]>和while循环http://www.cnblogs.com/spring_wang/p/6113514.html
C#基础总结之四List-Hashtable-冒泡排序http://www.cnblogs.com/spring_wang/p/6113504.html
C#基础总结之三循环控制-for-数组-乘法表-arraylisthttp://www.cnblogs.com/spring_wang/p/6113496.html
C#基础总结之二循环控制-运算符http://www.cnblogs.com/spring_wang/p/6113484.html
C#基础总结之一变量常量-if嵌套语句-witch结构-类型转换http://www.cnblogs.com/spring_wang/p/6113476.html
C#基础课程之六(临时表)DataTable使用方法http://www.cnblogs.com/spring_wang/p/6113454.html
C#基础课程之五集合(HashTable,Dictionary)http://www.cnblogs.com/spring_wang/p/6113404.html
C#基础课程之四集合(ArrayList、List<泛型>)http://www.cnblogs.com/spring_wang/p/6113396.html
C#基础课程之三循环语句http://www.cnblogs.com/spring_wang/p/6113383.html
C#基础课程之二变量常量及流程控制http://www.cnblogs.com/spring_wang/p/6113372.html
C#基础课程之一注释和控制台、一些常识http://www.cnblogs.com/spring_wang/p/6113361.html
C#基础第九天-作业答案-储蓄账户(SavingAccount)和信用账户(CreditAccount) http://www.cnblogs.com/spring_wang/p/6113291.html
C#基础第九天-作业-储蓄账户(SavingAccount)和信用账户(CreditAccount) http://www.cnblogs.com/spring_wang/p/6113285.html
C#基础第八天-作业答案-设计类-面向对象方式实现两个帐户之间转账http://www.cnblogs.com/spring_wang/p/6113274.html
C#基础第八天-作业-设计类-面向对象方式实现两个帐户之间转账http://www.cnblogs.com/spring_wang/p/6113258.html
C#基础第七天-作业答案-利用面向对象的思想去实现名片-动态添加http://www.cnblogs.com/spring_wang/p/6113232.html
C#基础第七天-作业-利用面向对象的思想去实现名片-动态添加http://www.cnblogs.com/spring_wang/p/6113224.html
C#基础第六天-作业-利用面向对象的思想去实现名片http://www.cnblogs.com/spring_wang/p/6113028.html
C#基础第六天-作业答案-利用面向对象的思想去实现名片http://www.cnblogs.com/spring_wang/p/6113033.html
C#基础第五天-作业答案-用DataTable制作名片集http://www.cnblogs.com/spring_wang/p/6113022.html
C#基础第五天-作业-用DataTable制作名片集http://www.cnblogs.com/spring_wang/p/6113013.html
C#基础第四天-作业答案-Hashtable-list<KeyValuePair>泛型实现名片http://www.cnblogs.com/spring_wang/p/6113005.html
C#基础第四天-作业-Hashtable-list<KeyValuePair>泛型实现名片http://www.cnblogs.com/spring_wang/p/6113000.html
C#基础第三天-作业答案-集合-冒泡排序-模拟名片http://www.cnblogs.com/spring_wang/p/6112888.html
C#基础第三天-作业-集合-冒泡排序-模拟名片http://www.cnblogs.com/spring_wang/p/6112885.html
C#基础第二天-作业答案-九九乘法表-打印星星http://www.cnblogs.com/spring_wang/p/6112881.html
C#基础第二天-作业-九九乘法表-打印星星http://www.cnblogs.com/spring_wang/p/6112875.html
C#基础第一天-作业答案http://www.cnblogs.com/spring_wang/p/6112872.html
C#基础第一天-作业http://www.cnblogs.com/spring_wang/p/6112867.html
C#-string.Format对C#字符串格式化http://www.cnblogs.com/spring_wang/p/6077098.html
C#基础课程之五集合(HashTable,Dictionary)的更多相关文章
- C#基础课程之四集合(ArrayList、List<泛型>)
list泛型的使用 ArrayList list = new ArrayList(); ArrayList list = ); //可变数组 list.Add("我"); //Ad ...
- 集合Hashtable Dictionary Hashset
#region Dictionary<K,V> Dictionary<string, Person> dict = new Dictionary<string, Pers ...
- C#基础总结之五Dictionary<string, string[]>和while循环
#region 第五天作业 名片集(01) //Dictionary<string, string[]> PersonCard = new Dictionary<string, st ...
- C#基础课程之六(临时表)DataTable使用方法
DataTable 用法:赋取值操作,及报错情况 dataTable.Columns.Add("Name"); //Columns 对象获取该集合的全部列,添加列名. 默认stri ...
- C#基础课程之三循环语句
for循环: ; i < ; i++) { Console.WriteLine("执行"+i+"次"); } while循环: while (true) ...
- C#基础课程之一注释和控制台、一些常识
注释是程序员对代码的说明,以使程序具有可读性.源代码在编译的过程中,编译器会忽略其注释部分的内容. ()行注释 格式为:// 注释内容 用两个斜杠表示注释的开始,直到该行的结尾注释结束. ()块注释 ...
- [转帖]C#中字典集合HashTable、Dictionary、ConcurrentDictionary三者区别
C#中字典集合HashTable.Dictionary.ConcurrentDictionary三者区别 https://blog.csdn.net/yinghuolsx/article/detail ...
- Redis基础课程讲义
Redis基础 课程内容 Redis入门 Redis数据类型 Redis常用命令 在Java中操作Redis 1. 前言 1.1 什么是Redis Redis是一个基于内存的key-value结构数据 ...
- C#泛型集合之Dictionary<k, v>使用技巧
1.要使用Dictionary集合,需要导入C#泛型命名空间 System.Collections.Generic(程序集:mscorlib) 2.描述 1).从一组键(Key)到一组值(Value) ...
随机推荐
- 【Android Studio】Android Studio 安装及设置
版权所有, 禁止转载, 如有需要, 请站内联系. 本文地址: http://blog.csdn.net/caroline_wendy/article/details/20845807 时间: 2014 ...
- atitit.为什么java体系开发效率这样低的原因and解决
atitit.为什么java体系开发效率这样低的原因and解决 #---开发理念问题(影响度:很大的,2-3倍效率) mvc<>webform server control ajax< ...
- ooj1057: M的整数倍DP
http://121.249.217.157/JudgeOnline/problem.php?id=1057 1057: M的整数倍 时间限制: 1 Sec 内存限制: 64 MB提交: 130 ...
- [推荐]dubbo分布式服务框架知识介绍
[推荐]dubbo分布式服务框架知识介绍 CentOS+Jdk+Jboss+dubbo+zookeeper集群配置教程 http://wenku.baidu.com/view/20e8f36bf ...
- android: 调用摄像头拍照
很多应用程序都可能会使用到调用摄像头拍照的功能,比如说程序里需要上传一张图片 作为用户的头像,这时打开摄像头拍张照是最简单快捷的.下面就让我们通过一个例子来学 习一下,如何才能在应用程序里调用手机的摄 ...
- RabbitMQ的工作队列和路由
工作队列:Working Queue 工作队列这个概念与简单的发送/接收消息的区别就是:接收方接收到消息后,可能需要花费更长的时间来处理消息,这个过程就叫一个Work/Task. 几个概念 分 ...
- ZZmsvcprt.lib(MSVCP90.dll) : error LNK2005:已经在libcpmtd.lib(xmutex.obj) 中定义 .的分析解决办法 (转)
很久没有写程式设计入门知识的相关文章了,这篇文章要来谈谈程式库 (Library) 连结,以及关于 MSVC 与 CRT 之间的种种恩怨情仇. 如果你使用的作业系统是 Linux.Mac 或其他非 W ...
- 创建一个Windows的NTP Server
搭建一个VMware vRealize Suite的时候遇见了不少时间同步的问题, 实验室里网络与外界隔绝, 不能使用公网的NTP服务器, 所以使用文中的方法自己搭建了一个. 蛮好用的. Creati ...
- Postman测试Web API
如何查看查询字符串? →输入包含查询字符串的URL,比如:http://localhost:54176/api/ProductCategories?name=darren&age=25→点击P ...
- Spring MVC+Quartz 定时任务持久化
请自行参考: http://sloanseaman.com/wordpress/2011/06/06/spring-and-quartz-and-persistence/ https://object ...