添加单个、对象或多个、
删除指定单个、范围、清空、
是否 包含、不包含、
索引直接修改
列表:ArrayList
ArrayList list = new ArrayList();
list.Add("111");
list.AddRange(new int[] {1, 2, 3, 4});
list.InsertRange(0, new int[] { 5, 5});
list.RemoveAt(0);
list.RemoveRange(0, 2);
list.Clear();
bool b1 = list.Contains(10);
Console.WriteLine(b1);
if (!list.Contains(1))
{
Console.WriteLine("不包含");
}
list[0] = "222";
for (int i = 0; i < list.Count; i++)
{
Console.WriteLine(list[i]);
}
字典 :Hashtable
Hashtable ht = new Hashtable();
ht.Add(1, "对对对");
ht[7] = "是是是";
ht.Remove(1);
foreach (var item in ht.Keys)
{
Console.WriteLine(ht[item]);
}
if (!ht.Contains("abc"))
{
Console.WriteLine("未包含,现在添加");
ht.Add("abc", "按不出");
}
else
{
Console.WriteLine("已包含");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)