Dictionary(数据字典)
数据字典:Dictionary对象用于在结对的名称/值中存储信息(等同于键和项目),其可作为传参使用。
C# Dictionary字典类的使用方法
//定义字典
Dictionary<string, string> d = new Dictionary<string, string>();
//添加字典的元素
for (int i = 0; i < 5; i++)
{
d.Add("key" + i, "value" + i);
}
//取值/赋值
string val = d["key1"];
d["key1"] = "new value";
//遍历key
foreach (string key in d.Keys)
{
Console.WriteLine("Key = {0}", key);
}
//遍历value
foreach (string v in d.Values)
{
Console.WriteLine("value = {0}", v);
}
//遍历value, Second Method
Dictionary<string, string>.ValueCollection valueColl = d.Values;
foreach (string s in valueColl)
{
Console.WriteLine("Second Method, Value = {0}", s);
}
//遍历字典
foreach (KeyValuePair<string, string> kvp in d)
{
Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
//删除元素
d.Remove("key1");
if (!d.ContainsKey("key1"))
{
Console.WriteLine("Key \"key1\" is not found.");
}
//判断键存在
if (d.ContainsKey("key1")) // True
{
Console.WriteLine("An element with Key = \"key1\" exists.");
}
Dictionary(数据字典)的更多相关文章
- Data Dictionary 数据字典
数据字典是一种通用的程序设计方法.可以认为,不论什么程序,都是为了处理一定的主体,这里的主体可能是人员.商品(超子).网页.接口.数据库表.甚至需求分析等等.当主体有很多的属性,每种属性有很多的取值, ...
- Oracle数据字典详解
学习笔记:oracle数据字典详解 --- 本文为TTT学习笔记,首先介绍数据字典及查看方法,然后分类总结各类数据字典的表和视图.然后列出一些附例. 数据字典系统表,保存在system表空间中. ...
- 6种innodb数据字典恢复方法
6种innodb数据字典恢复方法 https://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting-datadict.html frm文件重 ...
- oracle 数据字典
select * from dictionary; --数据字典 数据字典是Oracle存放有关数据库信息的地方,其用途是用来描述数据的. 比如一个表的创建者信息,创建时间信息,所属表空间信息,用户访 ...
- Java基础常见英语词汇
Java基础常见英语词汇(共70个) ['ɔbdʒekt] ['ɔ:rientid]导向的 ['prəʊɡræmɪŋ]编程 OO: object ...
- IT软件开发常用英语词汇
Aabstract 抽象的abstract base class (ABC)抽象基类abstract class 抽象类abstraction 抽象.抽象物.抽象性access 存取.访问access ...
- computer English
算法常用术语中英对照Data Structures 基本数据结构Dictionaries 字典PriorityQueues 堆Graph Data Structures 图Set Data Struc ...
- DDL(Oracle)
DDL 数据定义 建表 建视图 建其他 drop create table t (a varchar2 (10));可变字符串最大为10 transaction - ...
- 尚学堂马士兵Oracle教程笔记
检查Oracle安装 首先,以超级管理员的身份登录oracle sqlplus sys/bjsxt as sysdba 然后,解除对scott用户的锁 alter user scott account ...
- 最全的ORACLE-SQL笔记
-- 首先,以超级管理员的身份登录oracle sqlplus sys/bjsxt as sysdba --然后,解除对scott用户的锁 alter user scott account unloc ...
随机推荐
- MyEclipse中 使用svn更新jar包 出现 svn cleanup failed–previous operation has not finished; run cleanup if it was interrupted 导致整个svn异常处理
svn cleanup failed–previous operation has not finished; run cleanup if it was interrupted 2014-07-02 ...
- [Nuxt] Display Vuex Data Differently in Each Page of Nuxt and Vue.js
You often use the same data in different ways across pages. This lesson walks you through setting up ...
- [Angular2 Animation] Basic animation
@Component({ selector: 'app-courses', templateUrl: './courses.component.html', styleUrls: ['./course ...
- php中的转义字符(用反斜杠\来输出,和C语言一样)
php中的转义字符(用反斜杠\来输出,和C语言一样) 一.总结 1.引号中的变量:双引号会替换变量的值,而单引号会把它当做字符串输出. 2.引号中的转义字符:双引号将用变量的值(test)代替它的名称 ...
- 同一master,两个slave的server_id相同问题处理
错误日志报错如下: 2017-09-15 18:45:59 1660 [Note] Slave I/O thread: Failed reading log event, reconnecting t ...
- POJ 3100 Root of the Problem || 1004 Financial Management 洪水!!!
水两发去建模,晚饭吃跟没吃似的,吃完没感觉啊. ---------------------------分割线"水过....."--------------------------- ...
- [Angular2 Animation] Control Undefined Angular 2 States with void State
Each trigger starts with an “undefined” state or a “void” state which doesn’t match any of your curr ...
- php 文件夹是否存在,不存在就创建
$lujing = "./nihao/wohao"; if(!is_dir($liujing)){ mkdir(iconv("UTF-8", "GBK ...
- 【15.07%】【codeforces 625A】Guest From the Past
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- hadoop一些常见报错的解决方式
Failed to set setXIncludeAware(true) for parser 遇到此问题通常是jar包冲突的问题. 一种情况是我们向java的lib文件夹加入我们自己的jar包导致h ...