shree.pat18's answer is of course right. But I want to explain this question a little bit more if you let me..
Let's look at how Decimal.ToParse(string)
method implemented;
public static Decimal Parse(String s)
{
return Number.ParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo);
}
As you can see, this method uses NumberStyles.Number
by default. It is a composite number style and it's implemented like;
Number = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
AllowDecimalPoint | AllowThousands,
That means your string can have one of;
Since NumberStyles.Number
has AllowDecimalPoint
, it fits .
in your string but this style doesn't have AllowExponent
that's why it can't parse e-02
in your string.
That's why you need to use Decimal.Parse Method (String, NumberStyles)
overload since you can specify NumberStyles
yourself.