VS-C++ 系列:所有相关C++文章链接.
VS-C# 系列:所有相关C#文章链接.
bat 系列:所有相关bat文章链接.
Keil 系列:所有相关文章链接
所有内容均以最小系统调试成功;逐步提供低分源码工程下载!
保证每行代码都经过验证!
如有疑惑,欢迎留言,看见即回;祝好__by Dxg_LC
序言:
1、以上链接为方便整理查看资料用;伴随博文发布更新,如果有不正确处,感谢指正
2、因本人能力有限若有不正确之处或者相关超链接失效,请于相关文章内提醒@博主;灰常感谢
3、友情提醒1,勿要《一支烟 + 一杯茶 == 一坐一下午》 身体重要,革命本钱;
4、友情提醒2,多喝热水;
5、友情提醒3,听媳妇话+多点时间陪家人;
1、增加键值对的方法1
当键不存在,相当于插入此键值对,当插入重复键时,则会引发ArgumentException类型的异常。
using System.Collections.Generic
//键值 和 数值相互对应,方便快速查看数据;【注意,键值有且仅有1个】
Dictionary<String, String> pList = new Dictionary<String, String>();
try
{
if (pList.ContainsKey("Item1") == false)
{
pList.Add("Item1", "111");
}
if (pList.ContainsKey("Item2")== false)
{
pList.Add("Item2", "222");
}
if (pList.ContainsKey("Item3") == false)
{
pList.Add("Item3", "333");
}
}
catch (System.Exception e)
{
Console.WriteLine("Error: {0}", e.Message);
}
2、增加键值对的方法2【推荐】
当键不存在,相当于插入此键值对,当键存在时,相当于修改该键对应的值;
当Dictionary[Key]取值时,如果此Key不存在,则会引发KeyNotFoundException异常。
using System.Collections.Generic
//键值 和 数值相互对应,方便快速查看数据;【注意,键值有且仅有1个】
Dictionary<String, String> pList = new Dictionary<String, String>();
pList["Item1"] = "111";
pList["Item2"] = "222";
pList["Item3"] = "333";
3、移除键值
//移除所有的键和值
pList.Clear();
//移除键为"Item1"的键值对
pList.Remove("Item1");
Dxg-原创出品,如需转载,请注明出处;
欢迎收藏,点赞;"一键三联"走起,LOL