没有副本的C#数组切片 [英] C# Array slice without copy
本文介绍了没有副本的C#数组切片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将C#数组的子集传递给方法.我不在乎该方法是否覆盖数据,因此希望避免创建副本.
I'd like to pass a sub-set of a C# array to into a method. I don't care if the method overwrites the data so would like to avoid creating a copy.
有没有办法做到这一点?
Is there a way to do this?
谢谢.
推荐答案
更改方法以采用 IEnumerable< T>
或 ArraySegment< T>
.
然后您可以传递 new ArraySegment< T>(array,5,2)
这篇关于没有副本的C#数组切片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文