詳解C#中一維數(shù)組的插入

一維數(shù)組的插入:

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:域名注冊、網(wǎng)頁空間、營銷軟件、網(wǎng)站建設(shè)、謝家集網(wǎng)站維護(hù)、網(wǎng)站推廣。

實現(xiàn)效果:在1 2 3 后面插入4

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

namespace Array
{
  class Program
  {
    static void Main(string[] args)
    {
      int[] array = new int[] { 1, 2, 3 };
      int[] des = addArray(array, 4, 4); 
      foreach (int item in des)
      {
        Console.WriteLine(item );
      }
      Console.ReadLine();
    }
    static int[] addArray(int[] bornArray, int index, int value)
    {
      ArrayList list = new ArrayList(bornArray );
      if (index <0)
      {
        index =0 ;
      }
      if (index >bornArray .Length -1)
      {
        index = bornArray.Length;
      }
      list.Insert(index ,value );
      int[] des = new int[list.Count ];
      for (int i=0;i<list.Count;i++)
      {
        des[i] = (int)list[i];
      }
      return des;
    }
  }
}

當(dāng)前文章:詳解C#中一維數(shù)組的插入
網(wǎng)站路徑:http://muchs.cn/article24/gphhce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、云服務(wù)器、網(wǎng)站策劃、域名注冊、網(wǎng)站設(shè)計、外貿(mào)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營