You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -496,7 +496,7 @@ public static bool TryParse(string? str, IFormatProvider? provider, out {_quanti
496
496
/// Parse a unit string.
497
497
/// </summary>
498
498
/// <param name=""str"">String to parse. Typically in the form: {{number}} {{unit}}</param>
499
-
/// <param name=""provider"">Format to use when parsing number and unit. Defaults to <see cref=""CultureInfo.CurrentUICulture"" /> if null.</param>
499
+
/// <param name=""provider"">Format to use when parsing number and unit. Defaults to <see cref=""CultureInfo.CurrentCulture"" /> if null.</param>
500
500
/// <example>
501
501
/// Length.ParseUnit(""m"", new CultureInfo(""en-US""));
502
502
/// </example>
@@ -522,7 +522,7 @@ public static bool TryParseUnit(string str, out {_unitEnumName} unit)
522
522
/// <example>
523
523
/// Length.TryParseUnit(""m"", new CultureInfo(""en-US""));
524
524
/// </example>
525
-
/// <param name=""provider"">Format to use when parsing number and unit. Defaults to <see cref=""CultureInfo.CurrentUICulture"" /> if null.</param>
525
+
/// <param name=""provider"">Format to use when parsing number and unit. Defaults to <see cref=""CultureInfo.CurrentCulture"" /> if null.</param>
526
526
public static bool TryParseUnit(string str, IFormatProvider? provider, out {_unitEnumName} unit)
527
527
{{
528
528
return UnitParser.Default.TryParse<{_unitEnumName}>(str, provider, out unit);
@@ -925,29 +925,29 @@ public override string ToString()
925
925
/// Gets the default string representation of value and unit using the given format provider.
926
926
/// </summary>
927
927
/// <returns>String representation.</returns>
928
-
/// <param name=""provider"">Format to use for localization and number formatting. Defaults to <see cref=""CultureInfo.CurrentUICulture"" /> if null.</param>
928
+
/// <param name=""provider"">Format to use for localization and number formatting. Defaults to <see cref=""CultureInfo.CurrentCulture"" /> if null.</param>
/// Gets the string representation of this instance in the specified format string using the specified format provider, or <see cref=""CultureInfo.CurrentUICulture"" /> if null.
947
+
/// Gets the string representation of this instance in the specified format string using the specified format provider, or <see cref=""CultureInfo.CurrentCulture"" /> if null.
948
948
/// </summary>
949
949
/// <param name=""format"">The format string.</param>
950
-
/// <param name=""provider"">Format to use for localization and number formatting. Defaults to <see cref=""CultureInfo.CurrentUICulture"" /> if null.</param>
950
+
/// <param name=""provider"">Format to use for localization and number formatting. Defaults to <see cref=""CultureInfo.CurrentCulture"" /> if null.</param>
951
951
/// <returns>The string representation.</returns>
952
952
public string ToString(string format, IFormatProvider? provider)
Copy file name to clipboardExpand all lines: README.md
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,7 @@ RotationalSpeed r = Angle.FromDegrees(90) / TimeSpan.FromSeconds(2);
82
82
83
83
### <aname="culture"></a>Culture and Localization
84
84
85
-
The culture for abbreviations defaults to Thread.CurrentUICulture and falls back to US English if not defined. Thread.CurrentCulture affects number formatting unless a custom culture is specified. The relevant methods are:
85
+
The culture for abbreviations defaults to Thread.CurrentCulture and falls back to US English if not defined. Thread.CurrentCulture affects number formatting unless a custom culture is specified. The relevant methods are:
86
86
87
87
* ToString()
88
88
* GetAbbreviation()
@@ -93,8 +93,9 @@ var usEnglish = new CultureInfo("en-US");
93
93
varrussian=newCultureInfo("ru-RU");
94
94
varoneKg=Mass.FromKilograms(1);
95
95
96
-
// ToString() uses CurrentUICulture for abbreviation language and CurrentCulture for number formatting
97
-
Thread.CurrentThread.CurrentUICulture=russian;
96
+
// ToString() uses CurrentCulture for abbreviation language number formatting. This is consistent with the behavior of the .NET Framework,
97
+
// where DateTime.ToString() uses CurrentCulture for the whole string, likely because mixing an english date format with a russian month name might be confusing.
98
+
Thread.CurrentThread.CurrentCulture=russian;
98
99
stringkgRu=oneKg.ToString(); // "1 кг"
99
100
100
101
// ToString() with specific culture and custom string format pattern
0 commit comments