This is a C# Program to demonstrate culture names.
This C# Program Demonstrates Culture Names.
Here the CultureInfo object that is returned by this property and its associated objects determine the default format for dates, times, numbers, currency values, the sorting order of text, casing conventions, and string comparisons.
Here is source code of the C# Program to Demonstrate Culture Names. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Demonstrate Culture Names */ using System; using System.Globalization; using System.Threading; public class Info : MarshalByRefObject { public void ShowCurrentCulture() { Console.WriteLine("Culture of {0} in application domain {1}: {2}", Thread.CurrentThread.Name,AppDomain.CurrentDomain.FriendlyName, CultureInfo.CurrentCulture.Name); } } public class Example { public static void Main() { Info inf = new Info(); Thread.CurrentThread.Name = "MainThread"; Thread.CurrentThread.CurrentCulture=CultureInfo.CreateSpecificCulture("nl-NL"); inf.ShowCurrentCulture(); AppDomain ad = AppDomain.CreateDomain("Domain2"); Info inf2 = (Info)ad.CreateInstanceAndUnwrap(typeof(Info).Assembly.FullName, "Info"); inf2.ShowCurrentCulture(); Console.ReadLine(); } }
This C# program is used to demonstrate culture names. The culture name is used to represent information about a specific culture including the names of the culture, the writing system, and the calendar used, as well as access to culture-specific objects that provide information for common operations, such as formatting dates and sorting strings.
Assign the CurrentThread.Name value as a MainThread. The Current Culture is used to create a CultureInfo that represents the specific culture that is associated with the specified name. Then CreateInstanceAndWrap() function is used to create a new instance of the specified type.
Parameters specify the assembly where the type is defined, and the name of the type. Then the Assembly.fullName is used to get the display name of the assembly. Then ShowCurrentCulture() function is used to display the name in the assembly.
Culture of MainThread in application domain ConsoleApplication32.vshoot.exe : nl-NL Culture of MainThread in application domain Domain2 : nl-NL
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
- Apply for C# Internship
- Check Computer Science Books
- Apply for Computer Science Internship
- Check MCA Books
- Practice MCA MCQs