引用数组在C#中的一部分 [英] Referencing a part of an array in C#
本文介绍了引用数组在C#中的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有包含一些数据,也就是说,一个首部和一个实际数据的阵列。我需要通过包含在数组的方法中的数据,但我肯定希望避免其复制到另一个阵列。
I have got the array containing some data, say, a header and a real data. I need to pass the data contained in the array to a method, but I definitely want to avoid copying it to another array.
我认为像ArraySegment,但似乎没有我的情况下工作(或者也许我错了吗?)。
I thought of something like ArraySegment, but it seems not to work in my case (or maybe I'm wrong?).
那么,如何将阵列的一部分传递给方法,因为它是一个数组本身?
So, how to pass a part of an array to a method, as it was an array itself?
感谢您的答复!
干杯
推荐答案
var subArray = array.Skip(5).Take(10);
这篇关于引用数组在C#中的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文