Array concatenation in C#

后端 未结 4 1205
故里飘歌
故里飘歌 2020-12-11 19:48
  1. How do I smartly initialize an Array with two (or more) other arrays in C#?

    double[] d1 = new double[5];
    double[] d2 = new double[3];
    double[] dTota         
    
    
            
4条回答
  •  被撕碎了的回忆
    2020-12-11 20:29

    var dTotal = d1.Concat(d2).ToArray();
    

    You could probably make it 'better' by creating dTotal first, and then just copying both inputs with Array.Copy.

提交回复
热议问题