c# Dictionary字典类如何使用
- Dictionary<string, string> openWith = new Dictionary<string, string>();
- //添加元素
- openWith.Add("txt", "notepad.exe");
- openWith.Add("bmp", "paint.exe");
- openWith.Add("dib", "paint.exe");
- openWith.Add("rtf", "wordpad.exe");
- Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);
- //更改值
- openWith["rtf"] = "winword.exe";
- Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);
- //遍历key
- foreach (string key in openWith.Keys)
- {
- Console.WriteLine("Key = {0}", key);
- }
- //遍历value
- foreach (string value in openWith.Values)
- {
- Console.WriteLine("value = {0}", value);
- }
- //遍历字典
- foreach (KeyValuePair<string, string> kvp in openWith)
- {
- Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
- }
- Console.WriteLine("===============");
- //删除元素
- openWith.Remove("rtf");
- //遍历字典
- foreach (KeyValuePair<string, string> kvp in openWith)
- {
- Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
- }
c# Dictionary字典类如何使用的更多相关文章
- C#中的Dictionary字典类介绍
Dictionary字典类介绍 必须包含名空间System.Collection.Generic Dictionary里面的每一个元素都是一个键值对(由二个元素组成:键和值) 键必须是 ...
- (转)C#中的Dictionary字典类介绍
关键字:C# Dictionary 字典 作者:txw1958原文:http://www.cnblogs.com/txw1958/archive/2012/11/07/csharp-dictionar ...
- C# Dictionary字典类介绍
说明 必须包含名空间System.Collection.Generic Dictionary里面的每一个元素都是一个键值对(由二个元素组成:键和值) 键必须是唯一的,而值不需要唯 ...
- .net中的Dictionary字典类的使用方法
//定义字典 Dictionary<string, string> d = new Dictionary<string, string>(); //添加字典的元素 ; i &l ...
- Dictionary字典类介绍
说明 必须包含名空间System.Collection.Generic Dictionary里面的每一个元素都是一个键值对(由二个元素组成:键和值) 键必须是唯一的,而值不 ...
- Dictionary字典类使用范例
原文发布时间为:2009-11-04 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Web.UI.WebControls;using System ...
- C#中的Dictionary字典类常用方法介绍
using System.Collections.Generic;//引用命名空间//Dictionary可以理解为散列集合 public class DictionaryTest { public ...
- C# Dictionary 字典
C#中的Dictionary字典类介绍 关键字:C# Dictionary 字典 作者:txw1958原文:http://www.cnblogs.com/txw1958/archive/2012/ ...
- Swift字典类
在Foundation框架中提供一种字典集合,它是由“键-值”对构成的集合.键集合不能重复,值集合没有特殊要求.键和值集合中的元素可以是任何对象,但是不能是nil.Foundation框架字典类也分为 ...
随机推荐
- mysql数据库基础知识和认识
mysql 创建一个用户 hail,密码 hail,指定一个数据库 haildb 给 hail mysql -u root -ppassworduse mysql;insert into user(h ...
- Spring入门3.AOP编程
Spring入门3.AOP编程 代码下载: 链接: http://pan.baidu.com/s/11mYEO 密码: x7wa 前言: 前面学习的知识是Spring在Java项目中的IoC或DJ,这 ...
- LeetCode OJ:N-Queens(N皇后问题)
Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a d ...
- SpringInAction--Spring Web应用之SpringMvc 注解配置
Spring MVC 是当前Web服务器中常用的结构,今天就来学习这相关的知识,首先上图——Spring请求的时候所经历的坎坷之路: (书上原话,算是解释..) 在请求离开浏览器时① ,会带有用户所请 ...
- Linux:更改hostname主机名
更改hostname主机名 查看主机名 hostname 临时更改主机名 hostname youname 更改永久生效主机名 1)更改配置文件 vi /etc/sysconfig/network 2 ...
- ffmpeg jpeg图片播放失败之问题排查
播放jpeg时,avformat_find_stream_info出现以下问题,排查: [jpeg_pipe @ 0x146a80] Could not find codec parameters f ...
- Gradle2.0用户指南翻译——第二章. 概述
翻译项目请关注Github上的地址:https://github.com/msdx/gradledoc本文翻译所在分支:https://github.com/msdx/gradledoc/tree/2 ...
- 基于EasyDSS流媒体服务器实现的直播流管理与鉴权的后台方案
本文转自EasyDSS团队Marvin的博客:http://blog.csdn.net/marvin1311/article/details/73548929 最新版本的EasyDSS流媒体解决方案, ...
- $.ajax 的速度要快于 angular 里 $http (个别情况)
$.ajax: $http:
- Split功能的思想实现
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using S ...