Nic*_*ick 1 c# string list point
如果我有PointCollection:
var points = new PointCollection();
points.Add(new Point(0, 0));
points.Add(new Point(10, 10));
points.Add(new Point(20, 20));
points.Add(new Point(30, 30));
Run Code Online (Sandbox Code Playgroud)
我可以得到相应的string使用:
string str = points.ToString();
Run Code Online (Sandbox Code Playgroud)
现在str是:
0,0 10,10 20,20 30,30
我怎样才能得到相反的过程?
像这样的东西?
var points = str.Split(' ').Select(x =>
{
var c = x.Split(';');
return new Point(int.Parse(c[0]), int.Parse(c[1]));
}).ToList();
Run Code Online (Sandbox Code Playgroud)