I have a textbox accepting user input; I am trying to use this user input it to populate this member of one of my business objects:
public System.Decimal? ExchangeRateThe application is localized - I need to support at the same time cultures that accept these as valid inputs: "1,5" and "1.5" The code I have now is:
var culture = Thread.CurrentThread.CurrentUICulture; int exchangeRate; int.TryParse(txtExchangeRate.Text, NumberStyles.Number, culture, out exchangeRate); entity.ExchangeRate = exchangeRate;
When the user culture is set to a culture that expects the "1,5" format (comma as decimal separator) - e.g "ro-RO", I want the value that gets stored in entity.ExchangeRate to be 1.5; however, when running the code above, it gets converted to 15 instead.
Any suggestions on how to convert these various formats so that the data that gets stored in my business entity is "1.5" (point as decimal separator)?
Thanks.