forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewByteMembers.vb
98 lines (91 loc) · 3.6 KB
/
NewByteMembers.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
' Visual Basic .NET Document
Option Strict On
Imports System.Globalization
Module modMain
Public Sub Main()
CallToString()
Console.WriteLIne()
SpecifyFormatProvider()
Console.WRiteLine()
SpecifyFormatString()
Console.WriteLine()
FormatWithProviders()
End Sub
Private Sub CallToString()
' <Snippet2>
Dim bytes() As Byte = {0, 1, 14, 168, 255}
For Each byteValue As Byte In Bytes
Console.WriteLine(byteValue)
Next
' The example displays the following output to the console if the current
' culture is en-US:
' 0
' 1
' 14
' 168
' 255
' </Snippet2>
End Sub
Private Sub SpecifyFormatProvider()
' <Snippet3>
Dim bytes() As Byte = {0, 1, 14, 168, 255}
Dim providers() As CultureInfo = {New CultureInfo("en-us"), _
New CultureInfo("fr-fr"), _
New CultureInfo("de-de"), _
New CultureInfo("es-es")}
For Each byteValue As Byte In bytes
For Each provider As CultureInfo In providers
Console.Write("{0,3} ({1}) ", byteValue.ToString(provider), provider.Name)
Next
Console.WriteLine()
Next
' The example displays the following output to the console:
' 0 (en-US) 0 (fr-FR) 0 (de-DE) 0 (es-ES)
' 1 (en-US) 1 (fr-FR) 1 (de-DE) 1 (es-ES)
' 14 (en-US) 14 (fr-FR) 14 (de-DE) 14 (es-ES)
' 168 (en-US) 168 (fr-FR) 168 (de-DE) 168 (es-ES)
' 255 (en-US) 255 (fr-FR) 255 (de-DE) 255 (es-ES)
' </Snippet3>
End Sub
Private Sub SpecifyFormatString()
' <Snippet4>
Dim formats() As String = {"C3", "D4", "e1", "E2", "F1", "G", _
"N1", "P0", "X4", "0000.0000"}
Dim number As Byte = 240
For Each format As String In formats
Console.WriteLine("'{0}' format specifier: {1}", _
format, number.ToString(format))
Next
' The example displays the following output to the console if the
' current culture is en-us:
' 'C3' format specifier: $240.000
' 'D4' format specifier: 0240
' 'e1' format specifier: 2.4e+002
' 'E2' format specifier: 2.40E+002
' 'F1' format specifier: 240.0
' 'G' format specifier: 240
' 'N1' format specifier: 240.0
' 'P0' format specifier: 24,000 %
' 'X4' format specifier: 00F0
' '0000.0000' format specifier: 0240.0000
' </Snippet4>
End Sub
Private Sub FormatWithProviders()
' <Snippet5>
Dim byteValue As Byte = 250
Dim providers() As CultureInfo = {New CultureInfo("en-us"), _
New CultureInfo("fr-fr"), _
New CultureInfo("es-es"), _
New CultureInfo("de-de")}
For Each provider As CultureInfo In providers
Console.WriteLine("{0} ({1})", _
byteValue.ToString("N2", provider), provider.Name)
Next
' The example displays the following output to the console:
' 250.00 (en-US)
' 250,00 (fr-FR)
' 250,00 (es-ES)
' 250,00 (de-DE)
' </Snippet5>
End Sub
End Module