Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 添加两个整数数组_C#_Arrays - Fatal编程技术网

C# 添加两个整数数组

C# 添加两个整数数组,c#,arrays,C#,Arrays,我必须添加两个int[]数组,其中一个main int[]数组最初是空的。我想在主数组中添加另一个数组的元素。在主数组中,在主数组的最后一个位置将添加更多的附加项 我有一个数组- var planetNotInRange = new int[7] ; if(planetSign.Contains(tempFrind)) { var result = planetSign.Select((b, k) => b.Equals(tempFrind) ? k : -1)

我必须添加两个int[]数组,其中一个main int[]数组最初是空的。我想在主数组中添加另一个数组的元素。在主数组中,在主数组的最后一个位置将添加更多的附加项

我有一个数组-

var planetNotInRange = new int[7] ;

if(planetSign.Contains(tempFrind))
{
    var result = planetSign.Select((b, k) => b.Equals(tempFrind) ? k : -1)
                           .Where(k => k != -1).ToArray();

    // Here I want to add this result Array in to the planetNotInRange array, 
    // when ever there is some value in the result array.
}

这是在循环将给出一个整数数组的数量。现在我想一个接一个地在PLanetInRange数组中concat。

如果要向数组中添加元素,听起来不应该从数组开始。一旦创建了一个数组,它的大小就固定了

使用
列表
,您可以使用

list.AddRange(array);

我通常建议使用列表(和其他集合类型)而不是数组。显然,数组很有用,但它们比其他集合更原始、更低级。

不清楚您想做什么。请提供一个具体的例子,我有一个数组-var planetNotInRange=newint[7];var result=planetSign.Select((b,k)=>b.Equals(tempFrind)?k:-1)。其中(k=>k!=-1)。ToArray();这是在循环将给出一个整数数组的数量。现在我想一个接一个地在PLanetInRange数组中进行concat。不要将其作为注释添加到问题中-编辑完整的细节。你的意思是添加或合并两个数组吗?事实上,仍然不清楚结果应该是什么。请阅读。在你的问题弄清楚之前,这是在浪费每个人的时间——包括你自己的时间。请注意,不能增加数组的大小-可以替换元素,也可以创建新数组。