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!

  • 相关阅读:
    10.C# 构造函数
    9.C# 类
    8.C#友元程序集----可访问性相关
    7.C# 多态的实现
    4.C#虚方法virtual详解
    3.C#的访问权限修饰符
    2.静态类成员、静态构造函数、静态类
    1.面向对象的基本概念
    6.C# 释放非托管资源2
    原生js实现轮播图原理
  • 原文地址:https://www.cnblogs.com/marslin/p/3058717.html
Copyright © 2011-2022 走看看