c#获取数组中指定元素的索引

       //获取元素的索引
            ArrayList arrList = new ArrayList();
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == 8)
                {
                    arrList.Add(i);
                }
            }var newArray = arrList.ToArray();
            Console.WriteLine("[{0},{1}]", newArray[0], newArray[1]);

 

posted @ 2016-04-21 14:00  直钩钓鱼  阅读(15302)  评论(0编辑  收藏  举报