Follow us

Header Ads

Cultures Console Application

Cultures  Console Application

Program.cs

using System;
using System.Globalization;

namespace Cultures
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            //It can show current culture(It can show Date and Time of Current Country)
            //Console.WriteLine(CultureInfo.CurrentCulture);
            //en-US means US
            CultureInfo.CurrentCulture = new CultureInfo("en-US");
            DispalyCurrentCulture();
            CultureInfo.CurrentCulture = new CultureInfo("bs-Latn-BA");
            DispalyCurrentCulture();
        }

        private static void DispalyCurrentCulture()
        {
            Console.WriteLine("----------------------------");
            Console.WriteLine(CultureInfo.CurrentCulture.Name);
            Console.WriteLine(DateTime.Now);
            Console.WriteLine(CultureInfo.CurrentCulture.DisplayName);
            Console.WriteLine("----------------------------");
            //It can Show Date of Birth Country Wise
            string dateString = "2.8.2022";
            DateTime date = DateTime.Parse(dateString, new CultureInfo("bs-Latn-BA"));
            //D can Show Date of Birth accourding to Country
            Console.WriteLine(date.ToString("D"));
            Console.WriteLine("----------------------------");
            //1.600+1
            string numberString = "1.600";
            decimal number = decimal.Parse(numberString, new CultureInfo("en-US")) + 1;
            //C is use for Current Country Currency
            Console.WriteLine(number.ToString("C"));
        }
    }
}


Post a Comment

0 Comments