Saturday, August 20, 2016

List all supported cultures name -C#

C#


List all supported cultures name


Below example will show you how to obtain the entire supported culture names. We use theSystem.Globalization.CultureInfo class to get this information. It provides a method called GetCultures() that returns an array of CultureInfo.


From this object we can get the culture name in languageCode-countryCode format and a culture name in English. Let see the code snippet below:


 


Click link for Download Code page : Zappmania_GlobalizationExample


using System;
using System.Collections.Generic;
using System.Globalization;

namespace Zappmania_GlobalizationExample.System.Globalization.Example

class MainCallingClass

static void Main(string[] args)

using (ListOfCultureInfo oListOfCulture = new ListOfCultureInfo())

oListOfCulture.GetListOfCulture();


class ListOfCultureInfo:IDisposable

CultureInfo[] cultures;
public void GetListOfCulture()

//
// Get the list of supported cultures filtered by the
// CultureTypes.
//
cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

//
// Iterates array of CultureInfo and print the culture name
// (language code-country code) and culture name in English.
//
foreach (CultureInfo culture in cultures)

Console.WriteLine(String.Format("0, -151",
culture.Name, culture.EnglishName));

Console.ReadLine();


// Implement IDisposable.
public void Dispose()

if (cultures != null)

cultures = null;
GC.SuppressFinalize(this);





 



List all supported cultures name -C#

No comments:

Post a Comment