convert char array to int array c#

后端 未结 6 996
抹茶落季
抹茶落季 2021-01-01 22:45

I have this array

char[] A = [\'1\', \'2\', \'3\', \'4\']

And I want to convert it to int[]

int[] Aint=[1, 2, 3, 4]
         


        
6条回答
  •  既然无缘
    2021-01-01 23:22

    Another option, using Array.ConvertAll and Char.GetNumericValue:

    int[] Aint = Array.ConvertAll(A, c => (int)Char.GetNumericValue(c));
    

提交回复
热议问题