I have the following block of code:
string price = \"1,234.56\";
decimal value = 0;
var allowedStyles = (NumberStyles.AllowDecimalPoint & NumberStyles.AllowT
The result of this binary and
(&
) will always be 0
(false
, or NumberStyles.None
). That's why it doesn't allow decimal and thousand separators:
var allowedStyles = (NumberStyles.AllowDecimalPoint & NumberStyles.AllowThousands);
Change to binary or
(|
):
var allowedStyles = (NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands);