如何在特定索引处插入列表 [英] How to insert list at specific index

查看:84
本文介绍了如何在特定索引处插入列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

123
456
abc
def

我已经使用list< string>我应该在123之后插入abc,在456之后插入def,不要在像list1.Insert()这样的特定索引处使用应该是通用的.我该怎么做

123
456
abc
def

I have used list<string> variable .I should insert abc after 123 and def after 456 not using at specific index like list1.Insert(); .It should be generic.How can i do this

推荐答案

``通用''表示使用通用,如List< int>中所示.就像您说的那样,使用通用列表,Insert会在您插入的位置获取索引.那么,这是什么问题呢?如果使用的是旧的非泛型类ArrayList,则存在相同的方法.因此,或者没有问题,或者您需要更好地解释.
''Generic'' means using generics, as in List<int>. With a generic List, Insert takes the index where you insert, just as you said. So, what is the issue ? If you were using ArrayList, the old non generic class, the same method exists. So, either there is no issue, or you need to explain better.


这篇关于如何在特定索引处插入列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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