c# - Decimal parse of exponential 0 value (0+E3) -


our middle tier sends serialized objects , 0, due math operations in java on server, come through 0e+3. when deserializing object xmlexception --> system.overflowexception because value large or small decimal.

why can't decimal.parse handle conversion?

is there way protect our client these numbers coming in way?

you try:

decimal.parse(numbertext, system.globalization.numberstyles.any) 

edit:

this doesn't work 0e+3 unfortunately

works:

console.writeline(decimal.parse("0", system.globalization.numberstyles.any)); console.writeline(decimal.parse("123.45", system.globalization.numberstyles.any)); console.writeline(decimal.parse("1.35e+6", system.globalization.numberstyles.any)); console.writeline(decimal.parse("1.54e-5", system.globalization.numberstyles.any)); 

doesn't work:

console.writeline(decimal.parse("0e+3", system.globalization.numberstyles.any)); 

is problem number 0e+3?

if so, write helper method handle this:

decimal parsedecimal(string number) {     if (number.equals("0e+3", stringcomparison.ordinalignorecase))     {         return 0;     }      return decimal.parse(number, system.globalization.numberstyles.any); } 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -