替换清单项目 [英] Replace list item

查看:55
本文介绍了替换清单项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将List<>的项目设置到第一个位置?

例如

How to set an item of a List<> to the first location?

e.g.

List <int> list = new List<int>

list.Add(10);
list.Add(20);
list.Add(30);
list.Add(40);



如何将值30设置为列表中的第一个位置?



How to set the value 30 to the first postion in the list?

推荐答案

以下一项取决于您要替换还是插入.

One of the following depending on whether you want to replace or insert.

list[0] = 30;
list.Insert(0, 30);


艾伦(Alan)


Alan


这篇关于替换清单项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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