In other words, System.Double is free to treat
the "G" format specifier differently than the System.Integer type. Moreover, your own type??”say,
type Employee??”is free to implement a format string in whatever way it likes. For example, a format
string of "SSN" could create a string based on the Social Security number of the employee.
nNote It??™s even more useful to allow your own types to handle a format string of "DBG", thus creating a
detailed string that represents the internal state to send to a debug output log.
Let??™s take a look at some example code that exercises these concepts:
Imports System
Imports System.Globalization
Imports System.Windows.Forms
Public Class EntryPoint
Shared Sub Main()
Dim current As CultureInfo = CultureInfo.CurrentCulture
Dim germany As CultureInfo = New CultureInfo("de-DE")
Dim russian As CultureInfo = New CultureInfo("ru-RU")
Dim money As Double = 123.45
Dim localMoney As String = money.ToString("C", current)
MessageBox.Show(localMoney, "Local Money")
localMoney = money.ToString("C", germany)
MessageBox.Show(localMoney, "German Money")
localMoney = money.ToString("C", russian)
MessageBox.Show(localMoney, "Russian Money")
End Sub
End Class
CHAPTER 9 n WORKING WITH STRINGS 173
This code listing will display the three message boxes shown in Figure 9-1.
Pages:
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294