//ArrayList arry = new ArrayList();
//arry.Add(1);
//arry.Add(2);
//arry.Add(3);
//arry.Add(4);
//arry.Add(5);
//for (int i = 0; i < arry.Count; i++)
//{
// Console.WriteLine(arry[i]);
//}
foreach
//foreach (object item in arry)
//{
// Console.WriteLine(item);
//}
//Add
//ArrayList arry1 = new ArrayList();
//ArrayList arry2 = new ArrayList();
//arry2.Add(1);//1
//arry2.Add(2);//2
//arry2.Add(3);//3
//arry1.Add(0);//0
//arry1.AddRange(arry2);
//arry1.Add(4);//4
//foreach (object item in arry1)
//{
// Console.WriteLine(item);//01234
//}
//ArrayList arry = new ArrayList();
//Console.WriteLine(arry.Count);
//arry.Add(1);
//arry.Add(1);
//arry.Add(1);
//Console.WriteLine(arry.Count);
//arry.Clear();
//Console.WriteLine(arry.Count);
//ArrayList arry = new ArrayList();
//arry.Add(1);
//arry.Add(2);
//arry.Add(3);
//arry.Add(4);
//arry.Add(5);
//Console.WriteLine(arry.Contains(4));
//bool flag = false;
//for (int i = 0; i < arry.Count; i++)
//{
// if ((int)arry[i] == 4)
// {
// flag = true;
// break;
// }
//}
//Console.WriteLine(flag);
//ArrayList arry = new ArrayList();
//arry.Add(1);
//arry.Add(2);
//arry.Add(3);
//arry.Add(4);
//arry.Add(1);
//arry.Add(5);
//Console.WriteLine(arry.IndexOf(1));
//Console.WriteLine(arry.LastIndexOf(1));
//ArrayList arry = new ArrayList();
//arry.Insert(0, "A");
//arry.Insert(0, "B");
//arry.Insert(0, "C");
//foreach (object item in arry)
//{
// Console.WriteLine(item);
//}
//ArrayList arry = new ArrayList();
//arry.Add(1);
//arry.Add(2);
//arry.Add(3);
//arry.Add(4);
//arry.Add(1);
//arry.Add(5);
//foreach (var item in arry)
//{
// Console.WriteLine(item);
//}
//Console.WriteLine("移除前---------------");
//Console.WriteLine(arry.Count);
//Console.WriteLine("---------------移除4");
//arry.RemoveAt(arry.IndexOf(4));
//foreach (var item in arry)
//{
// Console.WriteLine(item);
//}
//Console.WriteLine("移除后---------------");
//Console.WriteLine(arry.Count);
//Console.WriteLine("---------------")
//Hashtable hash = new Hashtable();
//hash.Add("zh", "中国");
//hash.Add("jp", "日本");
//if (!hash.ContainsKey("zh"))
//{
// //hash.ContainsValue("中国");
// hash.Add("zh", "中国");
//}
//hash.Remove("jp");
//Console.WriteLine(hash.Count);
//foreach (object item in hash)
//{
// Console.WriteLine(item);
//}
//Console.WriteLine("-------------------转码后");
//foreach (object item in hash)
//{
// DictionaryEntry dic = (DictionaryEntry)item;
// Console.WriteLine(dic.Key + "................." + dic.Value);
//}
//SortedList sort = new SortedList();
//sort.Add("1", "中国");
//sort.Add("2", "日本");
//sort.Add("3", "美国");
//sort.Add("4", "英国");
Console.WriteLine(sort["zh"]);
arratlist
//Console.WriteLine(sort.GetByIndex(0));
//Console.WriteLine(sort.GetKey(0));
//foreach (object item in sort.GetKeyList())
//{
// Console.WriteLine("ket:{0}------------value:{1}",item,sort[item]);
//}
//foreach (object item in sort.GetValueList())
//{
// Console.WriteLine(item );
//}
//Stack stack = new Stack();
//stack.Push("A");
//stack.Push("B");
//stack.Push("C");
//stack.Pop();
//Console.WriteLine(stack.Count);
//int j = stack.Count;
//for (int i = 0; i < j; i++)
//{
// Console.WriteLine(stack.Pop());
//}
//Console.WriteLine(stack.Count);
//for (int i = 0; i < stack.Count; i++)
//{
// Console.WriteLine(stack.Peek());
//}
//Console.WriteLine(stack.Count);
//foreach (object item in stack)
//{
// Console.WriteLine(item);
//}
//Queue q = new Queue();
//q.Enqueue(1);
//q.Enqueue(2);
//q.Enqueue(3);
//q.Enqueue(4);
//q.Enqueue(5);
//Console.WriteLine(q.Dequeue());
//foreach (object item in q)
//{
// Console.WriteLine(item);
//}
C#基础【六】集合
最新推荐文章于 2024-09-04 17:42:36 发布