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) ...
随机推荐
- atitit.基于http json api 接口设计 最佳实践 总结o7
atitit.基于http json api 接口设计 最佳实践 总结o7 1. 需求:::服务器and android 端接口通讯 2 2. 接口开发的要点 2 2.1. 普通参数 meth,p ...
- 学习IT资源分享,欢迎各位知道的学习IT资源前来分享
1:排序不是按照名次,随机排序 慕课学习网https://www.imooc.com/ 腾讯课堂 https://ke.qq.com/ 柠檬学院 http://bjlemon.edusoho.cn/ ...
- Android组件Spinner使用
Spinner组件是Android当中非常常用的一种用于下拉选择的组件. 本blog当中主要解决的几个问题: 如何在XML中初始化Spinner选项 如何使用代码的方式初始化Spinner选项 一个A ...
- 多层嵌套对象无法使用gson反序列化的问题The JsonDeserializer com.google.gson.DefaultTypeAdapters$CollectionTypeAdapter@3bf13cde failed to de
http://www.oschina.net/question/1256646_123691 http://bbs.csdn.net/topics/360005140 http://stackover ...
- Python学习笔记(2):数据库访问
本来打算继续用Access的,但费了非常大的劲,还是没有搞定.回过头,发现使用sqlite,简单到令人发指.干脆,把C#的CommonCode往这边迁移,先把AccessDB搬过来再说. 类结构和C# ...
- 软件设计之UML—UML中的六大关系
一.UML中的六大关系 在UML类图中,常见的有以下几种关系: 泛化(Generalization), 实现(Realization),关联(Association),聚合(Aggregation), ...
- 致第一次安装RIME的你
转载自百度RIME吧,作者:半月湾C 原帖地址:http://tieba.baidu.com/p/3288634121 序言 很喜欢小狼毫输入法,喜欢他的简洁,美观以及超强悍的个人定制功能.关于 ...
- Linux每天定时重启Tomcat服务
1:查看crond 服务状态(确认Linux任务计划服务开启) service crond status crond (pid 1937) is running... 2:编写重启Tomcat的sh ...
- MySQL 服务无法启动。 服务没有报告任何错误。 请键入 NET HELPMSG 3534 以获得更多的帮助。
网上搜了下,看到有几种解决方法,本人综合了一下,作为记录 第一步 有一部分人成功了 在安装根目录创建data文件夹 第二步 有一部分人成功了 D:\Program Files\mysql\bin> ...
- iOS 语言切换、本地化,国际化
什么是本地化处理? 本地化处理就是我们的应用程序有可能发布到世界的很多国家去,因为每个国家应用的语言是不一样的,所以我们要把我们的应用程序的语言要进行本地化处理一下. 本地化处理需要处理那些文件? ( ...