C# 在ArrayList中的Insert方法示例

namespace ConsoleApplication1
{

  class Program
  {
      static void Main(string[] args)
      {

          ArrayList numbers = new ArrayList();
          numbers.Add(10);
          numbers.Add(22);
          numbers.Add(3);

          numbers.Add(5);
          numbers.Add(9);
          Console.WriteLine("The elements of the arraylist are:");
          foreach (int i in numbers)

          {
              Console.WriteLine(i);
          }
          numbers.Insert(0, "One");

          numbers.Insert(4, "Two");
          numbers.Insert(5, "Three");
          Console.WriteLine("After performing the insert operation the arraylist is:");
          foreach (object i in numbers)

          {
              Console.WriteLine(i);
          }
      }

  }
}
C# 在ArrayList中的Insert方法

Insert方法将元素插入到指定索引中的ArrayList中。

日期:2020-04-11 23:03:41 来源:oir作者:oir