我为值做了一个Regex过滤器。double
例如,一个TextBox包含音量,我将其regex用于
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.
}
当0我0,5进入TextBox.