I have a string, which sometimes has to be separated from the number such as "code" 1,500 and I have to change it for any int, it is throwing an exception at present, someone can tell me how to fix this so that sometimes I can remove the input number and other time with commas with a comma and now it is Will also change
You can use and add a flag:
Int num = int.Parse (toParse, NumberStyles.AllowThousands);
Or to tell you when the operation is successful:
int num; Use {// successful pars, 'num'}, if (int.TryParse (toParse, NumberStyles.AllowThousands, CultureInfo.InvariantCulture, num))
No comments:
Post a Comment