c# - How do I convert string to decimal? -


I have this text box that accepts numbers, commas, and periods.

Suppose that the input 14,500.00

in this text box is from the Convert.ToDecimal (textbox.text) Tried to change in decimal but it is not working. Convert. ToDecimal () text box containing input, in which format XXXX.DD is converted to decimal, but format X, XXX.DD Or an input with a thousand splitter results with error:

The input string was not in the correct format

is < Code> convert toDecimal () in this case is appropriate?

Additional information:

Enter image details here

Here is the form if I click on 'add', then the product of 'price' and 'quantity' should be displayed as 'zodiac' in the datagrid view.

The syntax in the 'Add' button includes:

  DataRow dr; Dr = dsDetail.Tables ["Sales Sale Details"]. NewRow (); Dr. ["zodiac"] = Convert toDecimal (txtSellingPrice.Text) * Convert toDecimal (txtQuantity.Text);  

The amount in my area field field> sales sales details is the data type in the table decimal (18,2)

You can force a culture and use decimals.

  decimal decimal = decimals Purse ("14,500.00", culture, infographic culture); // 14500  

What is converted in this case. Is DWAbl Perfect?

Yes, you convert toDecimal if you want:

  d = convert toDecimal ("14,500.00", CultureInfo .invariantCulture);  

Comments