c# - 如何在 C# 中截断列表?

标签 c# list truncate

我知道在 python 中你可以做类似 myList[1:20] 的事情,但在 C# 中有类似的东西吗?

最佳答案

var itemsOneThroughTwenty = myList.Take(20);
var itemsFiveThroughTwenty = myList.Skip(5).Take(15);

关于c# - 如何在 C# 中截断列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3428242/

相关文章:

c# - 为什么 IEnumerator<T> 会影响 IEnumerable<T> 的状态,即使 ienumerator 从未到达终点?

c# - MSChart插入、移动、删除点

c# - 如何在C#中使用SHA256withRSA算法进行签名

python - python 列表中的 Writerows - 如何删除括号和撇号

php - 截断中文文本

C# 可能有一个通用的返回类型吗?

python - 如何从 Pandas DataFrame 的列内列表中删除值

python - 剪辑二维列表直到内容形成一个矩形(Python)

c - 快速 float 到整数的转换(截断)

javascript - 将 JS 对象中的所有属性返回到 "empty"状态