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!

  • 相关阅读:
    poj-2478 Farey Sequence(dp,欧拉函数)
    codeforces 515C C. Drazil and Factorial(水题,贪心)
    hdu-5643 King's Game(打表)
    可以在命令行直接使用密码来进行远程连接和远程拉取文件的命令:sshpass
    查看SQL运行时间
    管理kafka
    No module named _sqlite3
    ps
    Redis之RDB与AOF
    Redis 4 参数解释
  • 原文地址:https://www.cnblogs.com/marslin/p/3058717.html
Copyright © 2011-2022 走看看