C# Decimal Parse(String, IFormatProvider)
Description
Decimal Parse(String, IFormatProvider)
converts the
string representation of a number to its Decimal equivalent using the specified
culture-specific format information.
Syntax
Decimal.Parse(String, IFormatProvider)
has the following syntax.
public static decimal Parse(
string s,
IFormatProvider provider
)
Parameters
Decimal.Parse(String, IFormatProvider)
has the following parameters.
s
- The string representation of the number to convert.provider
- An IFormatProvider that supplies culture-specific parsing information about s.
Returns
Decimal.Parse(String, IFormatProvider)
method returns The Decimal number equivalent to the number contained in s as specified by
provider.
Example
The following code shows how to use Decimal.Parse(String, IFormatProvider)
method.
using System;/*from ww w . j av a 2s .co m*/
using System.Globalization;
public class MainClass
{
public static void Main(String[] argv)
{
decimal number;
number = Decimal.Parse("123", CultureInfo.InvariantCulture.NumberFormat);
System.Console.WriteLine(number);
}
}
The code above generates the following result.