Click to See Complete Forum and Search --> : is price a number - regexp problem


abab
July 1st, 2009, 10:46 AM
I have something like that:

Regex reg = new Regex(@"^\d+(\.\d\d)?$");
if (!reg.IsMatch(book.price))
{
}


But I have an error:
Error 4 Argument 1: cannot convert from 'decimal' to 'string'


What should I do ?

memeloo
July 1st, 2009, 11:36 AM
is book.price of type deciaml?
then I suggest you write
book.price.ToString()

boudino
July 2nd, 2009, 02:47 AM
If book.price is decimal such the error points, the price is number, there is nothing to check.