Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CultureInfo (es) ToDecimal()
Message
 
 
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01653447
Message ID:
01653508
Views:
46
That was an interesting question indeed. Apparently we do send tnScanNo with characters. In my code I just moved TRY before the first line.

>Why would you expect to convert "P1111" to decimal ?
>Try:
public static long ToLong(this String tcString)
>        {
>            long result = 0;
>            long.TryParse(tcString, out result);
>            return result;
>        }
>
>
>
>>I am now getting this error
>>
>>System.FormatException: Input string was not in a correct format.
>> at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
>> at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
>> at System.Convert.ToDecimal(String value, IFormatProvider provider)
>>
>>
>>at this line of code
>>
>>
>>  //=====================================================================================================================
>>        public static long ToLong(this String tcString)
>>        {
>>            Decimal dDecimalValue = Convert.ToDecimal(tcString, CultureInfo.InvariantCulture);
>>            try { return (Int64)dDecimalValue; }
>>            catch { }
>>            return 0L;
>>        }
>>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform