DateTime date = DateTime.Now; CultureInfo[] cultures = { CultureInfo.GetCultureInfo("en-US"), CultureInfo.GetCultureInfo("fr-FR"), CultureInfo.GetCultureInfo("es-ES") }; foreach (CultureInfo culture in cultures) { Console.WriteLine(date.ToString(culture)); }
double price = 123.45; CultureInfo[] cultures = { CultureInfo.GetCultureInfo("en-US"), CultureInfo.GetCultureInfo("fr-FR"), CultureInfo.GetCultureInfo("es-ES") }; foreach (CultureInfo culture in cultures) { Console.WriteLine(price.ToString("C", culture)); }In this code example, we define a double variable for the price of a product. Then we define an array of CultureInfo objects for the English (United States), French (France), and Spanish (Spain) cultures. Finally, we loop through each culture and use the ToString method with the "C" format specifier to format the price as a currency value in the culture-specific format. Overall, the System.Globalization.CultureInfo package library is a powerful tool that allows developers to create applications that support different cultures around the world.