dotnet
dotnet copied to clipboard
Add IsCurrency to StringExtensions.
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 _);
}