-3

how to separate something from 83726473827 to

int[0] = 8;
int[1] = 3;
int[2] = 7;

etc...

I don't want use any separator

Suchy
  • 11
  • 2

1 Answers1

0

You can use Linq extension method Select with char.getNumericValue() like this:

using System.Linq;

string str = "83726473827";

int[] array = str.Select(c => (int)char.GetNumericValue(c)).ToArray();

foreach ( int value in array )
  Console.WriteLine(value);

We take each char of the string and convert them to numeric value as integer, then we take the result as an array.

This code assumes that the string contains only digits else we need to take in consideration other cases.

Output

8
3
7
2
6
4
7
3
8
2
7