没有合适的资源?快使用搜索试试~ 我知道了~
本文内容给大家分享了在C#中进行一维数组的插入的详细实例代码,大家可以测试下。
资源推荐
资源详情
资源评论


















详解详解C#中一维数组的插入中一维数组的插入
本文内容给大家分享了在C#中进行一维数组的插入的详细实例代码,大家可以测试下。
一维数组的插入:
实现效果:在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;
}
}
}
资源评论


weixin_38661087
- 粉丝: 3
- 资源: 979
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
