Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Converting string to decimal seems to be a familiar question. But in my case the an error is throwing while I tried to convert a string value "10.00000000000" to decimal. I tried following codes

Decimal a = Convert.Todecimal("10.0000000000000000") ;
decimal a = decimal.Parse("10.0000000000000000");

but failed.

I think the problem is with the "zeros"(10.0000000000000000). Can any one knows why this produce an exception. I forget the error. But I will let you know that by tomorrow.

Can any one help.. please.

share|improve this question

closed as off-topic by Muhammad Raja, RJ Cuthbertson, John Chapman, Robert Lindgren, Benny Skogberg MCSA Jul 10 '13 at 5:12

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Programming questions not specific to SharePoint are off-topic here, but can be asked on Stack Overflow." – Robert Lindgren, Benny Skogberg MCSA
  • "This question does not appear to be about SharePoint within the scope defined in the help center." – Muhammad Raja, RJ Cuthbertson, John Chapman
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
This doesn't seem related to SharePoint, so you may have better luck on stackoverflow.com. Anyway, check the decimal separator on the machine, it could be the source of the error. –  SPArchaeologist Apr 22 '13 at 14:28

1 Answer 1

I copy pasted your code and got a

'System.Convert' does not contain a definition of 'Todecimal'

and

'A local variable named a is already in defined in this scope'

Rewriting your code to a simple console app I didn't get any error at all:

        Decimal a = Convert.ToDecimal("10.0000000000000000");
        decimal b = decimal.Parse("10.0000000000000000");
        Console.WriteLine(a.ToString());
        Console.WriteLine(b.ToString());
        Console.Read();
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.