Here is the extension method. This is done in a string because you cannot add a static function to a string.
public static int[] ToIntArray(this string value) { return value.Split(',') .Select<string, int>(s => int.Parse(s)) .ToArray<int>(); }
This is how you use it
string testValue = "123, 456,789"; int[] testArray = testValue.ToIntArray();
It is assumed that you want to divide by ",", if not, then you need to change ToIntArray
David basarab
source share