C#中的JavaScript拼接 [英] JavaScript splice in c#
本文介绍了C#中的JavaScript拼接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
c#是否有类似的方法可以从JavaScript中拼接
?
Does c# has a similiar method to splice
from JavaScript?
我只知道 RemoveRange
,但这不会返回已删除的元素:
I only know RemoveRange
, and this does not return the removed elements:
List<string> t = new List<string>();
t.RemoveRange(..., ...);
(我想避免编写自己的收藏集).
(I want to avoid writing my own collection).
推荐答案
没有精确的 ,但是您可以写一个:
There is no exact equivelant but you can write one:
public static List<T> Splice<T>(this List<T> source,int index,int count)
{
var items = source.GetRange(index, count);
source.RemoveRange(index,count);
return items;
}
这篇关于C#中的JavaScript拼接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文