小编Exp*_*501的帖子

Double Regex gives back the wrong number

I made a Regex which filters for double values.

For example one TextBox contains volume and I use this regex for

double ConvertToDouble(String input)
{
    // Matches the first numebr with or without leading minus.
    Match match = Regex.Match(input, "[+-]?\\d*\\.?\\d+");

    if (match.Success)
    { 
        return Double.Parse(match.Value);
    }
    return 0; // Or any other default value.
}
Run Code Online (Sandbox Code Playgroud)

Somehow this returns 0 when I enter 0,5 into the TextBox.

c# regex double

-1
推荐指数
1
解决办法
48
查看次数

标签 统计

c# ×1

double ×1

regex ×1