用for循环遍历arraylist集合

SOASPX 13452 0

下面是C#控制台程序,用for循环遍历arraylist集合。

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication1
    { 
        class Program 
        { 
            static void Main(string[] args)
            {
                ArrayList list = new ArrayList();
                list.Add(1);
                list.Add(3.23); 
                for (int i = 0; i < list.Count; i++)
                {
                    Console.WriteLine(list[i]);
                }

                Console.ReadKey(); 
            }
        }
    }

发表评论 (已有0条评论)

还木有评论哦,快来抢沙发吧~