Tuesday, May 4, 2021

C# CultureInfo class

using System;
using System.Globalization; // to use CultureInfo class
namespace ConsoleCultureInfo
{
    class Program
    {
        static void Main(string[] args)
        {
            //get current culture info and its properties
            CultureInfo currentCi = CultureInfo.CurrentCulture;
            Console.Write("Name: ");
            Console.WriteLine(currentCi.Name);
            Console.Write("DisplayName: ");
            Console.WriteLine(currentCi.DisplayName);
            Console.Write("EnglishName: ");
            Console.WriteLine(currentCi.EnglishName);
            Console.Write("Default Calendar: ");
            Console.WriteLine(currentCi.Calendar);
            Console.Write("Native Name: ");
            Console.WriteLine(currentCi.NativeName);
            Console.Write("NumberFormat: ");
            Console.WriteLine(currentCi.NumberFormat);
            Console.ReadKey();
        }
    }
}

OUTPUT
Name: en-CA
DisplayName: English (Canada)
EnglishName: English (Canada)
Default Calendar: System.Globalization.GregorianCalendar
Native Name: English (Canada)
NumberFormat: System.Globalization.NumberFormatInfo

No comments:

Post a Comment

Hot Topics