How to convert a string into a Point?

c#, regex

Solution

Like this:

string[] coords = str.Split(',');

Point point = new Point(int.Parse(coords[0]), int.Parse(coords[1]));

Problem

I have a list of strings of the format "x,y". I would like to make them all into Points. The best Point constructor I can find takes two ints. What is the best way in C# to turn `"14,42"` into `new Point(14,42);`? I know the Regex for doing that is `/(\d+),(\d+)/`, but I'm having a hard time turning those two match groups into ints in C#.

Original source