C# string[] to int[]

arrays, c#, int, parsing, string

Solution

This linq query should do it:

strArray.Select(s => int.Parse(s)).ToArray()

Problem

Is there a way to convert string arrays to int arrays as easy as parsing an string to an int in C#. ``` int a = int.Parse(”123”); int[] a = int.Parse(”123,456”.Split(’,’)); // this don't work. ``` I have tried using extension methods for the int class to add this functionality myself but they don't become static. Any idea on how to do this fast and nice?

Original source

Related problems