File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,17 @@ public static bool IsDecimal([NotNullWhen(true)] this string? str)
68
68
return decimal . TryParse ( str , NumberStyles . Number , CultureInfo . InvariantCulture , out _ ) ;
69
69
}
70
70
71
+ /// <summary>
72
+ /// Determines whether a string is a valid as a currency.
73
+ /// </summary>
74
+ /// <param name="str">The string to test.</param>
75
+ /// <param name="culture">The culture to check against. If left null, <see cref="CultureInfo.CurrentCulture"/> is used.</param>
76
+ /// <returns><c>true</c> for a valid currency; otherwise, <c>false</c>.</returns>
77
+ public static bool IsCurrency ( [ NotNullWhen ( true ) ] this string ? str , CultureInfo ? culture = null )
78
+ {
79
+ return decimal . TryParse ( str , NumberStyles . Currency , culture ?? CultureInfo . CurrentCulture , out _ ) ;
80
+ }
81
+
71
82
/// <summary>
72
83
/// Determines whether a string is a valid integer.
73
84
/// </summary>
You can’t perform that action at this time.
0 commit comments