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?
This linq query should do it:
strArray.Select(s => int.Parse(s)).ToArray()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With