# 创建字典对象
主要由两部分构成 key和item,在括号中指明key 和 item 的类型。
`Dictionary <string, string> myDic = new Dictionary<string, string>();`
如果要创建的 item是 一个数组也行:
`Dictionary<string, string[]> myDic = new Dictionary<string, string[]>;`
![](https://img.kancloud.cn/da/2c/da2cbe29febc109e4c1d3464cdb68a74_754x279.png)
```
Dictionary<string, string> myDic = new Dictionary<string, string>(); //key 和 item 都是 string 类型
for (int i = 0; i < dt1.Rows.Count; i++) //将dt 中的元素添加到字典中
{
string k = "", value = "";
k = dt1.Rows[0][0].ToString();
value = dt1.Rows[0][0].ToString();
myDic.Add(k, value);
}
```
# value是一个类
[https://blog.csdn.net/kasama1953/article/details/51698567](https://blog.csdn.net/kasama1953/article/details/51698567)
# dictionary 转 dataTable
[https://blog.csdn.net/l974199574/article/details/52181284](https://blog.csdn.net/l974199574/article/details/52181284)
- 帮助文档 microsoft helo viewer
- c#开发环境及visual studio安装注意事项
- c#程序基本结构-基本语法
- Q1: public static void main(String[] args) 是什么意思
- Q2: c#命名空间+Main方法
- Q3:注释+命名规则+代码规则
- Q4: c#语句 system => console
- Q5: 数据类型 .net
- Q5: 常用名字、变量、运算符
- Q6: 对话窗输入-属性
- Q7: 递归
- Q8:决策分支、条件判断语句 if 语句
- Q9:数组
- Q10:字符串
- Q11:对象、类、访问权限、静态动态函数
- Q12:方法及参数——继承于类
- Q13:构造函数
- Q14:继承——base 关键字
- Q15:多态、虚方法、接口
- Q16:创建窗体应用、控件
- Q17:Ado数据访问、连接 sqlserver 数据库
- Q18: 读取数据command + DataRead( )、DataSet + DateAdapter
- Q19: Entity Framwork、entity 与 ADO.net的区别
- Q20: 对话框、文件、文件夹
- Q21: 导入excel数据、更新到 dbo 数据库中
- Q26: 获取 excel 中每个 sheet 的表名
- Q22: 两个窗体之间数据+方法传递
- Q23: 数学对象
- Q24: c#网站编写
- Q25: visual studio2017如何查看帮助
- Q27: c# dictionary 字典对象
- Q28: 数组与dataTable互相转化