在C#中设置特定范围的数组值

Kaj*_*ama 4 c# arrays

我正在寻找一种方法,如何为数组中的特定范围设置特定值.

像这样的东西

伪代码:

var s = new uinit[64];
s[ 0..15] := { 2, 4, 6, 3,  1, 7, 8, 9,  7, 11, 37, 32,  19, 16, 178, 2200 }
s[16..31] := ... 
Run Code Online (Sandbox Code Playgroud)

我试图在C#中找到这样的东西,但没有运气.我想尝试这样的事情:

public void SetArrayValues(int startIndex, uint[] values) 
{
    var length = values.Length;
    this.array[startIndex, startIndex + length] = values;
}
Run Code Online (Sandbox Code Playgroud)

我唯一能找到的是System.Array.SetValue,但这不符合我的要求.

我错过了什么吗?

在此先感谢您的帮助

Sae*_*ini 11

我认为你能做的最接近的是Array.Copy:

var s = new uint[64];
uint[] values = { 2, 4, 6, 3, 1, 7, 8, 9, 7, 11, 37, 32, 19, 16, 178, 2200 };

int sourceIndex = 0;
int destinationIndex = 0;
Array.Copy(values, sourceIndex , s, destinationIndex , values.Length);
Run Code Online (Sandbox Code Playgroud)