convert char array to int array c#

后端 未结 6 968
抹茶落季
抹茶落季 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 22:55

    Please do Like this

      char[] A = {'1', '2', '3', '4'};
      int[] Aint = new int[A.Length];      
      for (int i = 0;i < A.Length;i++)
      {
          Aint[i] = Convert.ToInt32(A[i].ToString()); 
      }
    

提交回复
热议问题