dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

Add IsCurrency to StringExtensions.

Open Arlodotexe opened this issue 2 years ago • 0 comments

Continuing from Currency validation support #4430.

We'd like to add an IsCurrency extension method to StringExtensions that bundles an easy and obvious check for if a string is a valid currency, similar to IsDecimal.

This would be implemented like so


public static bool IsCurrency([NotNullWhen(true)] this string? str)
{
    return decimal.TryParse(str, NumberStyles.Currency, out _);
}

Arlodotexe avatar Dec 20 '21 18:12 Arlodotexe