The CultureInfo.InvariantCulture property is neither a neutral nor a specific culture. It is a third type of culture that is culture-insensitive. It is associated with the English language but not with a country or region. You can use InvariantCulture in almost any method in the System.Globalization namespace that requires a culture.
// Parses the string stored in the file, // and stores it in a DateTime. DateTime dtout = DateTime.Parse(date, InvC); // Creates a CultureInfo set to "fr-FR". CultureInfo frc = new CultureInfo("fr-FR"); // Displays the date formatted for the "fr-FR" culture. Console.WriteLine("\nThe date read from the file and formatted for the culture \"fr-FR\" is:\n{0}" , dtout.ToString("d", frc)); // Creates a CultureInfo set to "ja-JP". CultureInfo jpn= new CultureInfo("ja-JP"); // Displays the date formatted for the "ja-JP" culture. Console.WriteLine("\nThe date read from the file and formatted for the culture \"ja-JP\" is:\n{0}" , dtout.ToString("d", jpn));
The date read from the file and formatted for the culture "fr-FR" is: 24/07/2001 The date read from the file and formatted for the culture "ja-JP" is: 2001/07/24
No comments:
Post a Comment