zoukankan      html  css  js  c++  java
  • ArrayList的Insert方法

    using System;
    using System.Collections;
    using System.Text;

    namespace myTest
    {
        class Program
        {
            static void Main(string[] args)
            {
                MyClass myClass = new MyClass();
                myClass.MyMethod();

                Console.ReadLine();
            }
        }

        class MyClass
        {
            public MyClass()
            {
                Console.WriteLine("测试类。");
            }
            public void MyMethod()
            {
                ArrayList myArrayList = new ArrayList(3);
                myArrayList.Add("Hello");
                myArrayList.Add("World!");

                myArrayList.Insert(1, "Jack ");
                myArrayList.Insert(2, "This is the ");

                Console.WriteLine("Capacity: {0}", myArrayList.Capacity);

                Console.WriteLine("Count: {0}", myArrayList.Count);

                Console.WriteLine(myArrayList[0]);
                Console.WriteLine(myArrayList[1]);
                Console.WriteLine(myArrayList[2]);
                Console.WriteLine(myArrayList[3]);
            }
        }
    }

    //测试结果
    //测试类。
    //Capacity: 6
    //Count: 4
    //Hello
    //Jack
    //This is the
    //World!

  • 相关阅读:
    各种 SDk
    面试第一周
    KVC/KVO 的概述和使用
    How Many Tables HDU
    The Suspects POJ
    Wireless Network POJ
    Layout POJ
    The Shortest Path in Nya Graph HDU
    Extended Traffic LightOJ
    Tram POJ
  • 原文地址:https://www.cnblogs.com/marslin/p/3058717.html
Copyright © 2011-2022 走看看