Created
March 8, 2017 20:40
-
-
Save javierguerrero/0fb74a7fef57c3e12fc9ce0e0cb67267 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private decimal ConvertStringNumberToDecimal(string importTransac) | |
{ | |
CultureInfo enUS = new CultureInfo("en-US"); | |
CultureInfo esAR = new CultureInfo("es-AR"); | |
CultureInfo originalCulture = CultureInfo.CurrentCulture; | |
decimal importe; | |
decimal parse; | |
System.Threading.Thread.CurrentThread.CurrentCulture = enUS; | |
if (decimal.TryParse(importTransac, out parse) == true) | |
{ | |
importe = decimal.Parse(importTransac); | |
} | |
else | |
{ | |
System.Threading.Thread.CurrentThread.CurrentCulture = esAR; | |
importe = decimal.Parse(importTransac); | |
} | |
System.Threading.Thread.CurrentThread.CurrentCulture = originalCulture; | |
return importe; | |
} | |
//importTransac = "11.748,00"; | |
//importTransac = "11,748.00"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment