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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version