我正在寻找一种方法,如何为数组中的特定范围设置特定值。
像这样
伪代码:
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] := ...
我试图在C#中找到类似的东西,但是没有运气。我正在尝试这样的事情:
public void SetArrayValues(int startIndex, uint[] values)
{
var length = values.Length;
this.array[startIndex, startIndex + length] = values;
}
我唯一能找到的是System.Array.SetValue,但这不符合我的要求。
我想念什么吗?
感谢您的任何帮助
我认为您可以通过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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句