集合与特殊集合

namespace 集合与特殊集合
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList al = new ArrayList();
            al.Add("李青");
            al.Add("约里克");
            al.Add("安妮");
            al.Add("盖伦");
            al.Add("卡萨丁");
            al.Add("布兰德");
            al.Add("诺克萨斯之手");
            al.Add("武器大师");
            al.Add("纳什之牙");
            al.Add("盲僧");
            al.Add("盖伦");
            al.Add("卡特琳娜");
            al.Add("九尾妖狐");
            //for (int i = 0; i < al.Count; i++)
            //{
            //    Console.WriteLine(al[i]); //依次输出
            //}

            //Console.WriteLine(al.Contains("诺克萨斯之手")); //看看是否包含
            //Console.WriteLine(al.IndexOf("卡特琳娜"));   //看看卡特琳娜的位置在哪(索引)
            //al.Insert(3, "德莱厄斯");   //在第三位前插入一个德莱厄斯
            //for (int i = 0; i < al.Count; i++)
            //{
            //    Console.WriteLine(al[i]);
            //}
            //al.LastIndexOf("盖伦");
            //Console.WriteLine(al.LastIndexOf("盖伦")); //最后一个盖伦的位置
            //al.Remove("约里克"); //把约里克删掉
            //for (int i = 0; i < al.Count; i++)
            //{
            //    Console.WriteLine(al[i]); //依次输出
            //}
            //al.RemoveAt(3);
            //for (int i = 0; i < al.Count; i++)
            //{
            //    Console.WriteLine(al[i]); //依次输出
            //}
            //al.Sort(); //按照首字母排序
            //for (int i = 0; i < al.Count; i++)
            //    {
            //        Console.WriteLine(al[i]); //依次输出
            //    }
            al.Reverse(); //翻转整个集合
            for (int i = 0; i < al.Count; i++)
                    {
                        Console.WriteLine(al[i]); //依次输出
                    }
            Console.ReadLine();
        }
    }
}

posted @ 2015-04-08 21:48  XCml  阅读(219)  评论(0编辑  收藏  举报