Living in Italy - work in Italian
Console.WriteLine(IsNumeric("$0")) ' False Console.WriteLine(IsNumeric("€0")) ' True Console.WriteLine(IsNumeric("£0")) ' False Console.WriteLine(IsNumeric("£")) ' False
until it always returns true
using System.Globalization; Console.WriteLine(MyIsNumeric("$0", NumberStyles.AllowCurrencySymbol, "en-US")) Console.WriteLine(MyIsNumeric("€0", NumberStyles.AllowCurrencySymbol, "it-IT")) Console.WriteLine(MyIsNumeric("£0", NumberStyles.AllowCurrencySymbol, "en-GB")) Public Function MyIsNumeric(ByVal val as String, ByVal NumberStyle as NumberStyles, cName as String) as Boolean Dim result as Double return Double.TryParse(val,NumberStyle, new CultureInfo(cName), result) End Function
So, we can conclude that IsNumeric (originally defined in the VB6 runtime) is smart enough to exclude the current locale currency symbols from its parsing if they precede or follow the input string.
Steve source share