C#数组赋值问题
数组1
byte[] byte1 = {1,2,3,4,5,6};
数组2
byte[] byte2;
如何将byte2指向数组1的一个子数组,如{2,3,4,5, 6}或者{3,4,5,6};
就像C++中的指针赋值:
byte2 = &byte1[3];
[解决办法]
class SubArray<T>{ private T[] _refarray; private int startpos; publc SubArray(T[] source, int startpos) { _refarray = source; _startpos = startpos; } public this[int index] { get { return _refarray[startpos + index]; } set { _refarray[startpos + index] = value; } }}