ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ToDecimal

Convert string to decimal

Source

public static decimal ToDecimal(this string value)
{
    decimal number;

    Decimal.TryParse(value, out number);

    return number;
}

Example

string number = "1.2";
decimal converted = number.Decimal();

Author: Túlio Henrique Thomé

Submitted on: 17 mei 2011

Language: C#

Type: System.String

Views: 7946