ArrayList的内容
数组列表的特点 可变长度,用法和数组类似
属性:Count (得到集合中的实际存放数据的个数)
ArryList 动态数组
方法:
Add() :向数组中添加一个元素
Remove() :删除数组中的某一元素
RemoveAt()删除数组中索引值为i的元素
Revese:反转数组的元素
Sort:从小到大排列数组的元素
Clone():复制一个数组
static void Main(string[] args)
{
ArrayList arrayList = new ArrayList();
arrayList.Add("hello world");//给动态数组单个添加一个方法//添加一个string类型的字符串
string[] names = { "小红","丽丽","涵涵"}
arrayList.AddRange(names);//集体添加
arrayList.Remove("丽丽")//移除值为丽丽的元素
arrayList.RemoveAt(2)//移除第二个元素//RemoveAt移除指定的东西
}
Hashtable的内容
Hashtable table=new Hashtable();
table.Add("qq","YangQiaoQiao");
table.Add("lxf","LiuXiaoFei");
table.Add("zl","ZhangLan");
foreach(DictionaryEntry item in table)
{
console.writeline(item.Key+" "+item.Value);
}
console.writeline("=================");
foreach(var item in table.Keys)
{
console.writeline(item);
}
console.wirteline("=================");
foreach(var item in tsble.Values)
{
console.writeline(item);
}