Figure 9-1. Results displayed from running the previous code listing
nNote In order to build the previous example, you??™ll need to add a reference to the System.Windows.
Forms.dll assembly, located in the Windows\Microsoft.NET\Framework\v2.0.xxxxx directory.
This example displays the strings using the MessageBox type defined in Windows.Forms,
since the console isn??™t good at displaying Unicode characters. The format specifier that we??™ve
chosen is "C" to display the number in a currency format. For the first display, you use the
CultureInfo instance attached to the current thread. For the following two, you create a
CultureInfo for both Germany and Russia. Note that in forming the string, the System.Double
type has used the CurrencyDecimalSeparator, CurrencyDecimalDigits, and CurrencySymbol
properties of the NumberFormatInfo instance returned from the CultureInfo.GetFormat
method. Had you displayed a DateTime instance, then the DateTime implementation of
IFormattable.ToString() would have utilized an instance of DateTimeFormatInfo returned
from the CultureInfo.GetFormat() in a similar way.
Console.WriteLine() and String.Format()
Throughout this book, you??™ve seen Console.WriteLine() used in the examples. One of the
forms of WriteLine() that is useful and identical to some overloads of String.
Pages:
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295