MoneyParse string

.MoneyParse()

Takes a string and converts it into a decimal while stripping out "$".

Method

public static decimal? MoneyParse(this string value, bool convertNullToZero = false)
string value

Money formatted string to convert to decimal.

bool convertNullToZero
Default: false

Converts a null value to a 0.

Example

C#
decimal? m = "$4.95".MoneyParse();