标签:
using System; using System.Collections.Generic;//数值链表的头文件 using System.Linq; using System.Text; using System.Collections;//数值链表的头文件 namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] nmbers = new int[5]; string[,] names = new string[5, 4]; byte[][] scores = new byte[5][]; for (int i = 0; i < scores.Length; i++) { scores[i] = new byte[i + 3]; } for (int i = 0; i < scores.Length; i++) { Console.WriteLine("Length of row{0} is {1}", i, scores[i].Length); int[] nmbers2 = new int[5] { 1, 2, 3, 4, 5 }; string[,] name2 = { { "g", "k" }, { "dd", "eee" } }; int a = nmbers2.Length; // Console.ReadLine(); } ArrayList al = new ArrayList(); //数值链表 al.Add(5); al.Add(100); al.Remove(5); al.Add("dfdfdfdfdf"); foreach (var a in al) { Console.WriteLine(a); } Console.WriteLine(al[0]); List<int> intList = new List<int>();//数值链表 intList.Add(500);//增加 intList.AddRange(new int[]{501,502});//增加 Console.WriteLine(intList.Contains(200));//是否存在某个数值 Console.WriteLine(intList.IndexOf(501));//查找第一次出现某个值得位置 intList.Remove(501);//删除 intList.Insert(1,1001);//插入 Hashtable ht = new Hashtable();//哈希表 类型不规定 ht.Add("first","jike"); //键值 数值 ht.Add("second","xueyuan"); Console.WriteLine(ht[99]); //不存在一个键值 返回为空 Dictionary<string, string> d = new Dictionary<string, string>();// 类型规定 强类型 线程不安全。线程安全是ConcurrentDictionary 多字典 d.Add("first","jike"); //不在一个键值,会抛出一个异常 Console.WriteLine(ht["second"]); SortedList<int, int> s1 = new SortedList<int, int>();//根据键值 排序 跟值大小、增加的顺序无关 s1.Add(5,105); s1.Add(2, 1025); s1.Add(4, 1055); s1.Add(6, 1015); s1.Add(7, 1005); s1.Add(51, 1035); s1.Add(35, 1095); foreach (var sle in s1) { Console.WriteLine(sle.Value);//可以键值和值进行 } //stack栈,queue队列 Console.ReadLine(); } } }
数组、数组链表ArrayList和List、Dictionary、SortedList、Hashtable
标签:
原文地址:http://www.cnblogs.com/heisaijuzhen/p/4461925.html