c# - validating decimal numbers in culture -
Can someone please explain that, in N-GB culture formatting, decimal Will the purse () function return to 155?
I see the same result of 'D' culture for the input of 1.5, the return is 15.
I know that this program is correct, I am just trying to understand why it is right. I googled it and came up with nothing: (
I am trying to validate user input against culture, and it is popping up the input field with 0 when parsing fails But populating the field with 15, they do not feel correct, when they enter 1,5, I think it should be "unsuccessful", when a 1,5 is entered to the English format, 15 Instead of returning.
try {ValidateSource.Text = decimal.Pars E (validateThis, NumberStyles.Number, UserCulture) .string ();} hold {validateSource.Text = "0";}
, is in the culture of the UK, there is no recognition of how many points in each group, so" 1,2,3 "parsed as 123 It will be done, even if it is not that we normally expect it to be written. However it would be wise to parsing the property, it is not just / P>
You can simulate this check by very in ancient fashion by formatting the results of parsing, and see R is equal to the original input: decimals Values; If (decimal troppers (text, numbers, number, culture, value)) {if (text! = Value.ToString ("N", culture)) {// OK, looks like something ... an error Of course, by stopping someone from entering "1234.56" as "1234.56", it can stop ... you want to see the multiple pattern, eg "n" And "live" to see if any of them match.
Comments
Post a Comment