詳解C#中一維數(shù)組的插入
更新時(shí)間:2018年03月25日 14:11:49 作者:彬菌
本文內(nèi)容給大家分享了在C#中進(jìn)行一維數(shù)組的插入的詳細(xì)實(shí)例代碼,大家可以測(cè)試下。
一維數(shù)組的插入:
實(shí)現(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; } } }
相關(guān)文章
解析C#中用Process類終止進(jìn)程,執(zhí)行命令的深入分析
本篇文章是對(duì)C#中用Process類終止進(jìn)程,執(zhí)行命令進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05利用C#實(shí)現(xiàn)將小數(shù)值四舍五入為整數(shù)
在項(xiàng)目的開發(fā)中,遇到一些除法計(jì)算內(nèi)容會(huì)產(chǎn)生小數(shù)值,但是又需要根據(jù)項(xiàng)目的實(shí)際情況將這些小數(shù)內(nèi)容化為整數(shù),所以本文為大家整理了C#實(shí)現(xiàn)將小數(shù)值四舍五入為整數(shù)的方法,希望對(duì)大家有所幫助2023-07-07C#將字節(jié)數(shù)組轉(zhuǎn)換成數(shù)字的方法
這篇文章主要介紹了C#將字節(jié)數(shù)組轉(zhuǎn)換成數(shù)字的方法,涉及C#類型轉(zhuǎn)換的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04深入DropDownList用法的一些學(xué)習(xí)總結(jié)分析
本篇文章是對(duì)DropDownList的用法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06UnityShader使用速度映射圖實(shí)現(xiàn)運(yùn)動(dòng)模糊
這篇文章主要為大家詳細(xì)介紹了UnityShader使用速度映射圖實(shí)現(xiàn)運(yùn)動(dòng)模糊,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-02-02c#調(diào)用api控制windows關(guān)機(jī)示例(可以重啟/注銷)
本文介紹了c#控制windows關(guān)機(jī)、重啟、注銷的二種方法,分為調(diào)用windows自帶的shutdown.exe關(guān)機(jī)和調(diào)用API關(guān)機(jī)的方法2014-01-01