@@ -98,24 +98,23 @@ var usEnglish = new CultureInfo("en-US");
98
98
var russian = new CultureInfo (" ru-RU" );
99
99
var oneKg = Mass .FromKilograms (1 );
100
100
101
- // ToString() with Thread.CurrentUICulture as US English and Russian respectively
102
- " 1 kg " == oneKg . ToString () ;
103
- " 1 кг " == oneKg .ToString ();
101
+ // Honors Thread.CurrentUICulture
102
+ Thread . CurrentUICulture = russian ;
103
+ string kgRu = oneKg .ToString (); // "1 кг"
104
104
105
105
// ToString() with specific culture and string format pattern
106
- " mg 1.00 " == oneKg .ToString (MassUnit .Milligram , usEnglish , " {1} {0:0.00}" );
107
- " мг 1,00 " == oneKg .ToString (MassUnit .Milligram , russian , " {1} {0:0.00}" );
106
+ string mgUs = oneKg .ToString (MassUnit .Milligram , usEnglish , " {1} {0:0.00}" ); // "mg 1.00"
107
+ string mgRu = oneKg .ToString (MassUnit .Milligram , russian , " {1} {0:0.00}" ); // "мг 1,00"
108
108
109
109
// Parse measurement from string
110
110
Mass kg = Mass .Parse (usEnglish , " 1.0 kg" );
111
- Mass kg = Mass .Parse (russian , " 1,0 кг" );
112
111
113
112
// Parse unit from string, a unit can have multiple abbreviations
114
- RotationalSpeedUnit . RevolutionPerMinute == RotationalSpeed .ParseUnit (" rpm" );
115
- RotationalSpeedUnit . RevolutionPerMinute == RotationalSpeed .ParseUnit (" r/min" );
113
+ RotationalSpeedUnit rpm1 == RotationalSpeed .ParseUnit (" rpm" ); // RotationalSpeedUnit.RevolutionPerMinute
114
+ RotationalSpeedUnit rpm2 == RotationalSpeed .ParseUnit (" r/min" ); // RotationalSpeedUnit.RevolutionPerMinute
116
115
117
116
// Get default abbreviation for a unit
118
- " kg " == Mass .GetAbbreviation (MassUnit .Kilogram );
117
+ string abbrevKg = Mass .GetAbbreviation (MassUnit .Kilogram ); // "kg"
119
118
```
120
119
121
120
<a name =" example-app " ></a >Example: Creating a unit converter app
0 commit comments