Passing one Dimension of a Two Dimensional Array in C#

后端 未结 6 987
耶瑟儿~
耶瑟儿~ 2021-01-21 07:31

I have moved from C to C#. I have a function which accepts an array. I want to pass one dimension of a Two Dimensional array to this function.

C Code would be:-

6条回答
  •  孤独总比滥情好
    2021-01-21 07:39

    A primitive way would be:

    var dimNumber = 1;
    
    int[] oneDimension = new int[50];
    
    for(var i=0; i<50; i++)
    {
       oneDimension[i] = Client_ID[dimNumber][i];
    }
    
    array_processing ( ref oneDimension);
    

    I would suggest using Lambda expressions like in the way 5 of zmbq's answer.

提交回复
热议问题