I want to convert from string {X=-24,Y=10}
which generated by Point.ToString();
to Point again?
I save the string value in xml file in save mode and I want read it back to point again in read mode.
var myStringWhichCantBeChanged="{X=-24,Y=10}";
var g=Regex.Replace(myStringWhichCantBeChanged,@"[\{\}a-zA-Z=]", "").Split(',');
Point pointResult = new Point(
int.Parse (g[0]),
int.Parse( g[1]));
System.Drawing.Point
doesn't define a Parse
method at all - you will need to write your own that can take this format and return a Point
structure.
System.Windows.Point
does have a Parse
method and may be more suitable for your needs.
However, since you are outputting to XML, non of this should be needed. You should be serializing and deserializng the object graph, which would take care of this automatically without you needing to worry about parsing and formatting.
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