泛型集合List Dictionary
来源:互联网 发布:网络钢琴家教 编辑:程序博客网 时间:2024/05/14 05:30
List<T>
ArrayList的所有方法
Sort(); 分类排序
Max(); 最大
Min();最小
Sum();求和
avatage(); 平均 T,K,V就像是锁,锁住集合中只能存放某种 特点的类型
泛型集合可以镜像foreach遍历,是因为他 们都实现了IEnumerable都有 GetEnumberator()方法
List<int> list=new List<int>(); 通过泛型可以限制集合中存 放的数据的类型
Dictionary<K,V> <键,值>
Dictionary<string,string>dict=new Dictionary<string,string>
dict.ContainsKey("zl") 返回bool类型
Console.WriteLine(dict["zl"])
Dictionary<string,Person>dict=new Dictionary<string,Person>
//值为类,,
Person p1 =new Person()
{}
遍历
/1遍历键
foreach(string item in dict.Keys)
{Console.WriteLine(item)}
/2遍历值
foreach(Person item in dict.Values)
{Console.WriteLine(item)}
/3键和值同时遍历
foreach(KeyValuePair<string,Person>kv in dict)
{Console.WriteLine("键:{0} 值:{1}",kv.Key,kv.Values)}
DictionaryEntry 包含键和值得类型。
用foreach遍历hash集合时用到
在里边用var定义 原因是 他是弱类型 在你还不知道你定义的是什么类型时用var 让系统判断是什么类型。。。
ArrayList的所有方法
Sort(); 分类排序
Max(); 最大
Min();最小
Sum();求和
avatage(); 平均 T,K,V就像是锁,锁住集合中只能存放某种 特点的类型
泛型集合可以镜像foreach遍历,是因为他 们都实现了IEnumerable都有 GetEnumberator()方法
List<int> list=new List<int>(); 通过泛型可以限制集合中存 放的数据的类型
Dictionary<K,V> <键,值>
Dictionary<string,string>dict=new Dictionary<string,string>
dict.ContainsKey("zl") 返回bool类型
Console.WriteLine(dict["zl"])
Dictionary<string,Person>dict=new Dictionary<string,Person>
//值为类,,
Person p1 =new Person()
{}
遍历
/1遍历键
foreach(string item in dict.Keys)
{Console.WriteLine(item)}
/2遍历值
foreach(Person item in dict.Values)
{Console.WriteLine(item)}
/3键和值同时遍历
foreach(KeyValuePair<string,Person>kv in dict)
{Console.WriteLine("键:{0} 值:{1}",kv.Key,kv.Values)}
DictionaryEntry 包含键和值得类型。
用foreach遍历hash集合时用到
在里边用var定义 原因是 他是弱类型 在你还不知道你定义的是什么类型时用var 让系统判断是什么类型。。。
- 泛型集合List Dictionary
- 黑马程序员---Dictionary<>字典,List<>泛型集合实例练习
- C#基础-059 泛型集合List<>与字典Dictionary<,>
- Dictionary 泛型集合
- Dictionary 泛型集合
- 随机数的种子问题、泛型集合:list Dictionary、字典Dictionary【充实的一天~!】
- string[] array arrayList hashtable list<> dictionary<,> 数组、集合、泛型集合
- Dictionary 泛型字典集合
- c# 泛型集合Dictionary
- c# 泛型集合Dictionary
- c# 泛型集合Dictionary
- Dictionary 泛型集合用法
- Dictionary 泛型字典集合
- c# 泛型集合Dictionary
- c# 泛型集合Dictionary
- C#泛型集合Dictionary
- C#集合类:Dictionary泛型集合
- C# 集合类:Dictionary 泛型集合
- 关于创业方向和资源的两篇文章:如何穷创业 + 创业者需要具备三种素质
- hdu 3491 Thieves
- HDU 1051 A New Growth Industry
- linux下出现ping:unknown host www.baidu.com问题时的解决办法——ubuntu下局域网络的配置
- Struts2中的OGNL表达式
- 泛型集合List Dictionary
- 线索化 树
- 【开发习惯】一、Java编程写出好代码
- 别让猴子跳回背上
- Struts2验证框架深度解析
- 孙鑫谈Java中文乱码问题产生原因分析
- UVaOJ 10494 - If We Were a Child Again
- 树状数组总结篇
- 自己实现的递归背包算法