c# - How to get format of currency using current culture information and validate that currency -
i have requirement have currency code , using code finding current culture of currency , symbol of currency.
here have ability change currency iso code , if user changes code according changing currency symbol.
now want find format of culture using currency iso code.which format culture uses currency.how can find that?
and using format want validation of currency.if user enter currency in wrong format want give validation how can that?
the decimal type, currency, has tryparse method accepts culture.
bool isvalidcurrency(string s, string tla, out value) { var culture = cultureinfo .getcultures(culturetypes.allcultures) .where(c => c.isocurrencysymbol == tla) .first(); return decimal.tryparse(s, numberstyles.any, culture, out value) } where s text representation of currency value , tla iso 3 letter abbreviation of currency.
Comments
Post a Comment