添加到数组方法? [英] Add to array method?

查看:91
本文介绍了添加到数组方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,

是否有一种方法可以使用索引向数组添加项目,例如添加到列表时。

Array.add(item)//例如



提前致谢,

z3ngew

Hello Everyone,
Is there a method to add items to an array with using index, like when adding to list.
Array.add(item)//for example

Thanks in advance,
z3ngew

推荐答案





Hi,

z3ngew写道:

z3ngew wrote:

就像添加时一样列出



那么,为什么你不使用列表

你可以转换一个列表使用 ToArray 方法到一个数组,你可以创建一个列表


So, why you don''t use a List?
You can convert a List to an array using the ToArray method, and you can create a List from an array using this code:

List<int> integerList = new List<int>(integerArray); // create a List from an array
// alternative way: List<int> integerList = integerArray.ToList();
// add some integers
integerArray = integerList.ToArray();



希望这有帮助。


Hope this helps.


这个帖子可以帮到你,



http ://stackoverflow.com/questions/249452/add-new-item-in-existing-array-in-c-net [ ^ ]
This thread should help you,

http://stackoverflow.com/questions/249452/add-new-item-in-existing-array-in-c-net[^]


Array.SetValue (对象值,int索引);
Array.SetValue(object value, int index);


这篇关于添加到数组方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆