Yes, I have tried regular expressions to try and do that but that will not handle the commas in the string. I could try and remove all commas from the string but I will not know if the comma is put in the correct place of the string.
I've been using the "try-catch" method of checking for number validation but it slowed down the execution time. I was looking of an alternative method to do it.
Hi,
Take a look here:
string s1="123.45";
double d=Convert.ToDouble(s1); // d=123.45
s1="-123,456.45";
d=Convert.ToDouble(s1); d=-123456.45
So, use Convert.ToDouble(string) in a try-catch bloc and there will be no slow down execution.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.