So I'm writing a program for a barcodescanner in C# .NET 3.5. When I scan the barcode I get an string with just numbers and I want that string to split at every number and put each number into an int array, but I can´t figure out how. Does someone of you know how to do that?
Try this:
int[] array = "1234567890".ToCharArray().Select(c => int.Parse(c.ToString())).ToArray();
Run Code Online (Sandbox Code Playgroud)
You can omit method invocation of ToCharArray as string is already collection of chars :)
| 归档时间: |
|
| 查看次数: |
84 次 |
| 最近记录: |