Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get a flag image from a C# CultureInfo?

If I have a CultureInfo instance, is there any simple way — built-in, through a framework or via the OS — to obtain a matching "flag" icon matching that culture? This would avoid having to create a separate lookup.

I couldn't find a member function to do the job in the documentation for CultureInfo, but perhaps there is some other not-too-taxing approach that involves other .NET classes that I haven't found.

like image 638
Lightness Races in Orbit Avatar asked Oct 31 '25 08:10

Lightness Races in Orbit


2 Answers

No. There is no simple, built-in way, through the .NET framework or the Windows operating system, to obtain a matching "flag" icon for a given CultureInfo instance.

like image 152
Peter Duniho Avatar answered Nov 02 '25 23:11

Peter Duniho


Extending Alex's answer. Once you have the ISO code, you can use this simple library to produce an ImageSource of the flag (from the famfamfam set) from the two character string:

https://github.com/drewnoakes/famfamfam-flags-wpf

It's not built in, but it is easy to use.

Images end up looking like this:

like image 45
Drew Noakes Avatar answered Nov 02 '25 23:11

Drew Noakes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!