Extract numbers from String

允我心安 提交于 2019-12-02 07:13:52

Why are you trying to parse the path markup syntax yourself? It's a complicated thing, and perhaps a subject to be changed (at least extended) in the future. WPF can do this for you: http://msdn.microsoft.com/en-us/library/system.windows.media.geometry.parse.aspx, so it's better to let the framework work.


Edit:
If the parsing is your bottleneck, you can try to parse yourself. I would recommend trying the following and checking if it's fast enough:

char[] separators = new char[] { ' ', ',' }; // should be created only once
var parts = pattern.Split(separators, StringSplitOptions.RemoveEmptyEntries);
double firstInPair = 0.0;
for (int i = 0; i < parts.Length; i++ )
{
    double number = double.Parse(parts[i]);
    if (i % 2 == 0)
    {
        firstInPair = number;
        continue;
    }
    double secondInPair = number;
    // do whatever you want with the pair (firstInPair, secondInPair) ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!