If you know the correct culture in advance (for example, because you know the user that created the file), you can try to parse the provided value using the appropriate CultureInfo
or NumberFormatInfo
:
Decimal value = Decimal.Parse(input, new CultureInfo("es-ES"));
But if the type is not known in advance, you'll have to check it manually by examining the characters until you find a separator. (And even that approach assumes that you are guaranteed to always have a decimal separator, such that one
is written as 1.0
rather than 1
.)
You can't just try each expected format one after the other because you may get false positives.
10,000
means something valid but different for both formats.