I am not sure how this can be correctly analyzed in C #, but I would like it to fail, where is the case where the comma is not divided by each repeated three values. Example: 1,123,23 should pass, but 11,23,23 should fail in my sense. But the actual conclusion is that tryparse seems to always return true no matter where the position of the comma is before the decimal point.
Edit: The regex response is accepted because it is detected to be an error. Thanks.
string price = "1,1,2,3.23"; decimal outputValue = 0; var allowedStyles = (NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands); if (Decimal.TryParse(price, allowedStyles, CultureInfo.GetCultureInfo("EN-us"), out outputValue)) { Console.WriteLine("Pass"); }
c #
stackdisplay
source share