James Hollingworth’s Adventures in Code

Get the currency symbol for the ISO 4217 Currency Code (C#)

with 2 comments

Had a bit of a problem today. After importing a bunch of transactions I needed to display the corresponding currency symbol. The problem was when you import OFX transactions, the currency is in the ISO 4217 three letter format. Basically the little bit of LINQ below will search through all the culture infos until it finds one with the correct ISO Currency symbol. Its little things like this that make me love linq!

RegionInfo regionInfo = (from c in CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures)
let r = new RegionInfo(c.LCID)
where r.ISOCurrencySymbol == “GBP”
select r).First();

Hope this is helpful to someone!

Written by jhollingworth

December 9, 2007 at 12:58 pm

Posted in .net, c#, linq, ofx

Tagged with

2 Responses to 'Get the currency symbol for the ISO 4217 Currency Code (C#)'

Subscribe to comments with RSS or TrackBack to 'Get the currency symbol for the ISO 4217 Currency Code (C#)'.

  1. Thanks that helped! Was unaware of the RegionInfo.ISOCurrencySymbol.

    Jon

    17 Jan 08 at 11:42 am

  2. Helped me a lot. And I was actually only wondering if I could get all the cultures and sort them through a query.

    Don’t you love LINQ?

    postbackmouton

    20 Jan 08 at 10:05 am

Leave a Reply