1 double value = 16325.62901; 2 string specifier; 3 CultureInfo culture; 4 5 // Use standard numeric format specifiers. 6 specifier = "G"; 7 culture = CultureInfo.CreateSpecificCulture("eu-ES"); 8 Console.WriteLine(value.ToString(specifier, culture)); 9 // Displays: 16325,62901 10 Console.WriteLine(value.ToString(specifier, CultureInfo.InvariantCulture)); 11 // Displays: 16325.62901 12 13 specifier = "C"; 14 culture = CultureInfo.CreateSpecificCulture("en-US"); 15 Console.WriteLine(value.ToString(specifier, culture)); 16 // Displays: $16,325.63 17 culture = CultureInfo.CreateSpecificCulture("en-GB"); 18 Console.WriteLine(value.ToString(specifier, culture)); 19 // Displays: £16,325.63 20 21 specifier = "E04"; 22 culture = CultureInfo.CreateSpecificCulture("sv-SE"); 23 Console.WriteLine(value.ToString(specifier, culture)); 24 // Displays: 1,6326E+004 25 culture = CultureInfo.CreateSpecificCulture("en-NZ"); 26 Console.WriteLine(value.ToString(specifier, culture)); 27 // Displays: 1.6326E+004 28 29 specifier = "F"; 30 culture = CultureInfo.CreateSpecificCulture("fr-FR"); 31 Console.WriteLine(value.ToString(specifier, culture)); 32 // Displays: 16325,63 33 culture = CultureInfo.CreateSpecificCulture("en-CA"); 34 Console.WriteLine(value.ToString(specifier, culture)); 35 // Displays: 16325.63 36 37 specifier = "N"; 38 culture = CultureInfo.CreateSpecificCulture("es-ES"); 39 Console.WriteLine(value.ToString(specifier, culture)); 40 // Displays: 16.325,63 41 culture = CultureInfo.CreateSpecificCulture("fr-CA"); 42 Console.WriteLine(value.ToString(specifier, culture)); 43 // Displays: 16 325,63 44 45 specifier = "P"; 46 culture = CultureInfo.InvariantCulture; 47 Console.WriteLine((value/10000).ToString(specifier, culture)); 48 // Displays: 163.26 % 49 culture = CultureInfo.CreateSpecificCulture("ar-EG"); 50 Console.WriteLine((value/10000).ToString(specifier, culture)); 51 // Displays: 163.256 %
时间: 2024-11-12 01:08:56