Dictionary<>的用法
来源:互联网 发布:网络电视啥功能 编辑:程序博客网 时间:2024/06/14 05:15
Dictionary比HashTable更好用
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace DictionaryUsage{ internal class Program { private static void Main(string[] args) { var dic = new Dictionary<int, string> {{1, "hang"}, {2, "hong"}, {3, "ximi"}}; //foreach (var temp in dic) //{ // Console.WriteLine("key: {0},value: {1}",temp.Key,temp.Value); //} //Console.WriteLine(dic); //var a = dic.Where(var => var.Key == 2).GetEnumerator().Current.Value; //Console.WriteLine(a); //取值 Console.WriteLine(dic[1]); //添加元素 dic.Add(4, "notepad.exe"); dic.Add(5, "paint.exe"); dic.Add(6, "paint.exe"); dic.Add(7, "wordpad.exe"); //更改值 dic[1] = "nihang1234"; //遍历字典 foreach (var temp in dic) { Console.WriteLine("key: {0},value: {1}", temp.Key, temp.Value); } //遍历键 foreach (var temp in dic.Keys) { Console.WriteLine(temp); } //遍历值 foreach (var temp in dic.Values) { Console.WriteLine(temp); } Console.ReadKey(); } }}
0 0
- Dictionary的用法
- Dictionary的用法
- c# Dictionary 的用法
- Dictionary<>的用法
- 泛型Dictionary的用法详解
- c#中Dictionary的用法
- Dictionary 与 KeyValue 的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- C#中Dictionary的用法
- 用硬件描述语言Verilog 设计一个抢答器
- IT 达人
- [JZOJ3809] 设备塔
- 1106. Lowest Price in Supply Chain (25)
- Winform DevExpress控件库(三) 使用NavBarControl控件定制导航栏
- Dictionary<>的用法
- sequence_loss_by_example(logits, targets, weights)
- Android的设计架构MVP,MVC
- Join操作基本:外连接、自然连接、内连接
- springmvc无法接收uploadify插件上传的数据
- 多线程之GCD,NSOperation和NSOperationQueue,NSThread
- iOS 条码及二维码扫描(从相册中读取条形码/二维码) 以及扫码遇到的问题
- Swift 之 UIACtionSheet
- wex5 实战 框架拓展之1 公共data组件(Data)