Skip to content

Commit e93e370

Browse files
authored
Sample fixes for batch 36 (dotnet#6730)
1 parent 3a966e5 commit e93e370

File tree

4 files changed

+70
-74
lines changed
  • samples/snippets
    • csharp/VS_Snippets_CLR_System
      • system.Security.Cryptography.RC2CryptoServiceProvider Example/CS
      • system.convert.toint64/cs
    • visualbasic/VS_Snippets_CLR_System
      • system.Security.Cryptography.RC2CryptoServiceProvider Example/VB
      • system.convert.toint64/vb

4 files changed

+70
-74
lines changed

samples/snippets/csharp/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/CS/class1.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void Main()
4040
byte[] encrypted = msEncrypt.ToArray();
4141

4242
///////////////////////////////////////////////////////
43-
// This is where the data could be transmitted or saved.
43+
// This is where the data could be transmitted or saved.
4444
///////////////////////////////////////////////////////
4545

4646
//Get a decryptor that uses the same key and IV as the encryptor.
@@ -55,13 +55,13 @@ public static void Main()
5555
// and place them in a StringBuilder class.
5656

5757
StringBuilder roundtrip = new StringBuilder();
58-
58+
5959
int b = 0;
6060

6161
do
6262
{
6363
b = csDecrypt.ReadByte();
64-
64+
6565
if (b != -1)
6666
{
6767
roundtrip.Append((char)b);
@@ -71,8 +71,6 @@ public static void Main()
7171
// Display the original data and the decrypted data.
7272
Console.WriteLine("Original: {0}", original);
7373
Console.WriteLine("Round Trip: {0}", roundtrip);
74-
75-
Console.ReadLine();
7674
}
7775
}
7876
}

samples/snippets/csharp/VS_Snippets_CLR_System/system.convert.toint64/cs/toint64_1.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ private static void ConvertChar()
8787
// The example displays the following output:
8888
// Converted the Char value 'a' to the Int64 value 97.
8989
// Converted the Char value 'z' to the Int64 value 122.
90-
// Converted the Char value '' to the Int64 value 7.
91-
// Converted the Char value '?' to the Int64 value 1023.
92-
// Converted the Char value '?' to the Int64 value 32767.
93-
// Converted the Char value '?' to the Int64 value 65534.
90+
// Converted the Char value '' to the Int64 value 7.
91+
// Converted the Char value 'Ͽ' to the Int64 value 1023.
92+
// Converted the Char value '翿' to the Int64 value 32767.
93+
// Converted the Char value '' to the Int64 value 65534.
9494
// </Snippet3>
9595
}
9696

@@ -145,15 +145,15 @@ private static void ConvertDouble()
145145
Console.WriteLine("{0} is outside the range of the Int64 type.", value);
146146
}
147147
}
148-
// -1.79769313486232E+308 is outside the range of the Int64 type.
149-
// -13800000000 is outside the range of the Int16 type.
148+
// -1.7976931348623157E+308 is outside the range of the Int64 type.
149+
// Converted the Double value '-13800000000' to the Int64 value -13800000000.
150150
// Converted the Double value '-1023.299' to the Int64 value -1023.
151151
// Converted the Double value '-12.98' to the Int64 value -13.
152152
// Converted the Double value '0' to the Int64 value 0.
153153
// Converted the Double value '9.113E-16' to the Int64 value 0.
154154
// Converted the Double value '103.919' to the Int64 value 104.
155155
// Converted the Double value '17834.191' to the Int64 value 17834.
156-
// 1.79769313486232E+308 is outside the range of the Int64 type.
156+
// 1.7976931348623157E+308 is outside the range of the Int64 type.
157157
// </Snippet5>
158158
}
159159

@@ -289,15 +289,15 @@ private static void ConvertSingle()
289289
}
290290
}
291291
// The example displays the following output:
292-
// -3.40282346638529E+38 is outside the range of the Int64 type.
293-
// -13799999488 is outside the range of the Int64 type.
294-
// Converted the Double value -1023.29901123047 to the Int64 value -1023.
295-
// Converted the Double value -12.9799995422363 to the Int64 value -13.
296-
// Converted the Double value 0 to the Int64 value 0.
297-
// Converted the Double value 9.11299983940444E-16 to the Int64 value 0.
298-
// Converted the Double value 103.918998718262 to the Int64 value 104.
299-
// Converted the Double value 17834.19140625 to the Int64 value 17834.
300-
// 3.40282346638529E+38 is outside the range of the Int64 type.
292+
// -3.4028235E+38 is outside the range of the Int64 type.
293+
// Converted the Single value -1.38E+10 to the Int64 value -13799999488.
294+
// Converted the Single value -1023.299 to the Int64 value -1023.
295+
// Converted the Single value -12.98 to the Int64 value -13.
296+
// Converted the Single value 0 to the Int64 value 0.
297+
// Converted the Single value 9.113E-16 to the Int64 value 0.
298+
// Converted the Single value 103.919 to the Int64 value 104.
299+
// Converted the Single value 17834.191 to the Int64 value 17834.
300+
// 3.4028235E+38 is outside the range of the Int64 type.
301301
// </Snippet10>
302302
}
303303

samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Module Crypto
3838
Dim encrypted As Byte() = msEncrypt.ToArray()
3939

4040
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
41-
' This is where the data could be transmitted or saved.
41+
' This is where the data could be transmitted or saved.
4242
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
4343

4444
'Get a decryptor that uses the same key and IV as the encryptor.
@@ -67,8 +67,6 @@ Module Crypto
6767
Console.WriteLine("Original: {0}", original)
6868
Console.WriteLine("Round Trip: {0}", roundtrip)
6969

70-
Console.ReadLine()
71-
7270
End Sub
7371
End Module
7472
'</snippet1>

samples/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.toint64/vb/toint64_1.vb

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Module modMain
3636
' <Snippet1>
3737
Dim falseFlag As Boolean = False
3838
Dim trueFlag As Boolean = True
39-
39+
4040
Console.WriteLine("{0} converts to {1}.", falseFlag, _
4141
Convert.ToInt64(falseFlag))
4242
Console.WriteLine("{0} converts to {1}.", trueFlag, _
@@ -46,12 +46,12 @@ Module modMain
4646
' True converts to 1.
4747
' </Snippet1>
4848
End Sub
49-
49+
5050
Private Sub ConvertByte()
5151
' <Snippet2>
5252
Dim bytes() As Byte = { Byte.MinValue, 14, 122, Byte.MaxValue}
5353
Dim result As Long
54-
54+
5555
For Each byteValue As Byte In bytes
5656
result = Convert.ToInt64(byteValue)
5757
Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", _
@@ -65,35 +65,35 @@ Module modMain
6565
' Converted the Byte value 255 to the Int64 value 255.
6666
' </Snippet2>
6767
End Sub
68-
68+
6969
Private Sub ConvertChar()
7070
' <Snippet3>
7171
Dim chars() As Char = { "a"c, "z"c, ChrW(7), ChrW(1023), _
7272
ChrW(Short.MaxValue), ChrW(&hFFFE) }
7373
Dim result As Long
74-
74+
7575
For Each ch As Char in chars
7676
result = Convert.ToInt64(ch)
7777
Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
7878
ch.GetType().Name, ch, _
7979
result.GetType().Name, result)
80-
Next
80+
Next
8181
' The example displays the following output:
8282
' Converted the Char value 'a' to the Int64 value 97.
8383
' Converted the Char value 'z' to the Int64 value 122.
84-
' Converted the Char value '' to the Int64 value 7.
85-
' Converted the Char value '?' to the Int64 value 1023.
86-
' Converted the Char value '?' to the Int64 value 32767.
87-
' Converted the Char value '?' to the Int64 value 65534.
84+
' Converted the Char value '' to the Int64 value 7.
85+
' Converted the Char value 'Ͽ' to the Int64 value 1023.
86+
' Converted the Char value '翿' to the Int64 value 32767.
87+
' Converted the Char value '' to the Int64 value 65534.
8888
' </Snippet3>
8989
End Sub
90-
90+
9191
Private Sub ConvertDecimal()
9292
' <Snippet4>
9393
Dim values() As Decimal = { Decimal.MinValue, -1034.23d, -12d, 0d, 147d, _
9494
199.55d, 9214.16d, Decimal.MaxValue }
9595
Dim result As Long
96-
96+
9797
For Each value As Decimal In values
9898
Try
9999
result = Convert.ToInt64(value)
@@ -103,8 +103,8 @@ Module modMain
103103
Catch e As OverflowException
104104
Console.WriteLine("{0} is outside the range of the Int64 type.", _
105105
value)
106-
End Try
107-
Next
106+
End Try
107+
Next
108108
' The example displays the following output:
109109
' -79228162514264337593543950335 is outside the range of the Int64 type.
110110
' Converted the Decimal value '-1034.23' to the Int64 value -1034.
@@ -116,13 +116,13 @@ Module modMain
116116
' 79228162514264337593543950335 is outside the range of the Int64 type.
117117
' </Snippet4>
118118
End Sub
119-
119+
120120
Private Sub ConvertDouble()
121121
' <Snippet5>
122122
Dim values() As Double = { Double.MinValue, -1.38e10, -1023.299, -12.98, _
123123
0, 9.113e-16, 103.919, 17834.191, Double.MaxValue }
124124
Dim result As Long
125-
125+
126126
For Each value As Double In values
127127
Try
128128
result = Convert.ToInt64(value)
@@ -131,10 +131,10 @@ Module modMain
131131
result.GetType().Name, result)
132132
Catch e As OverflowException
133133
Console.WriteLine("{0} is outside the range of the Int64 type.", value)
134-
End Try
135-
Next
134+
End Try
135+
Next
136136
' -1.79769313486232E+308 is outside the range of the Int64 type.
137-
' -13800000000 is outside the range of the Int16 type.
137+
' Converted the Double value '-13800000000' to the Int64 value -13800000000.
138138
' Converted the Double value '-1023.299' to the Int64 value -1023.
139139
' Converted the Double value '-12.98' to the Int64 value -13.
140140
' Converted the Double value '0' to the Int64 value 0.
@@ -144,12 +144,12 @@ Module modMain
144144
' 1.79769313486232E+308 is outside the range of the Int64 type.
145145
' </Snippet5>
146146
End Sub
147-
147+
148148
Private Sub ConvertInt16()
149149
' <Snippet6>
150150
Dim numbers() As Short = { Int16.MinValue, -1, 0, 121, 340, Int16.MaxValue }
151151
Dim result As Long
152-
152+
153153
For Each number As Short In numbers
154154
result = Convert.ToInt64(number)
155155
Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", _
@@ -165,7 +165,7 @@ Module modMain
165165
' Converted the Int16 value 32767 to the Int64 value 32767.
166166
' </Snippet6>
167167
End Sub
168-
168+
169169
Private Sub ConvertInt32
170170
' <Snippet7>
171171
Dim numbers() As Integer = { Int32.MinValue, -1, 0, 121, 340, Int32.MaxValue }
@@ -183,16 +183,16 @@ Module modMain
183183
' Converted the Int32 value 121 to the Int64 value 121.
184184
' Converted the Int32 value 340 to the Int64 value 340.
185185
' Converted the Int32 value 2147483647 to the Int64 value 2147483647.
186-
' </Snippet7>
187-
End Sub
188-
186+
' </Snippet7>
187+
End Sub
188+
189189
Private Sub ConvertObject()
190190
' <Snippet8>
191191
Dim values() As Object = { True, -12, 163, 935, "x"c, #5/12/2009#, _
192192
"104", "103.0", "-1", _
193193
"1.00e2", "One", 1.00e2, 16.3e42}
194194
Dim result As Long
195-
195+
196196
For Each value As Object In values
197197
Try
198198
result = Convert.ToInt64(value)
@@ -208,9 +208,9 @@ Module modMain
208208
Catch e As InvalidCastException
209209
Console.WriteLine("No conversion to an Int64 exists for the {0} value {1}.", _
210210
value.GetType().Name, value)
211-
211+
212212
End Try
213-
Next
213+
Next
214214
' The example displays the following output:
215215
' Converted the Boolean value True to the Int64 value 1.
216216
' Converted the Int64 value -12 to the Int64 value -12.
@@ -227,12 +227,12 @@ Module modMain
227227
' The Double value 1.63E+43 is outside the range of the Int64 type.
228228
' </Snippet8>
229229
End Sub
230-
230+
231231
Private Sub ConvertSByte()
232232
' <Snippet9>
233233
Dim numbers() As SByte = { SByte.MinValue, -1, 0, 10, SByte.MaxValue }
234234
Dim result As Long
235-
235+
236236
For Each number As SByte In numbers
237237
result = Convert.ToInt64(number)
238238
Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", _
@@ -247,32 +247,32 @@ Module modMain
247247
' Converted the SByte value 127 to the Int64 value 127.
248248
' </Snippet9>
249249
End Sub
250-
250+
251251
Private Sub ConvertSingle()
252252
' <Snippet10>
253253
Dim values() As Single = { Single.MinValue, -1.38e10, -1023.299, -12.98, _
254254
0, 9.113e-16, 103.919, 17834.191, Single.MaxValue }
255255
Dim result As Long
256-
256+
257257
For Each value As Single In values
258258
Try
259259
result = Convert.ToInt64(value)
260260
Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", _
261261
value.GetType().Name, value, result.GetType().Name, result)
262262
Catch e As OverflowException
263263
Console.WriteLine("{0} is outside the range of the Int64 type.", value)
264-
End Try
265-
Next
264+
End Try
265+
Next
266266
' The example displays the following output:
267-
' -3.40282346638529E+38 is outside the range of the Int64 type.
268-
' -13799999488 is outside the range of the Int64 type.
269-
' Converted the Double value -1023.29901123047 to the Int64 value -1023.
270-
' Converted the Double value -12.9799995422363 to the Int64 value -13.
271-
' Converted the Double value 0 to the Int64 value 0.
272-
' Converted the Double value 9.11299983940444E-16 to the Int64 value 0.
273-
' Converted the Double value 103.918998718262 to the Int64 value 104.
274-
' Converted the Double value 17834.19140625 to the Int64 value 17834.
275-
' 3.40282346638529E+38 is outside the range of the Int64 type.
267+
' -3.4028235E+38 is outside the range of the Int64 type.
268+
' Converted the Single value -1.38E+10 to the Int64 value -13799999488.
269+
' Converted the Single value -1023.299 to the Int64 value -1023.
270+
' Converted the Single value -12.98 to the Int64 value -13.
271+
' Converted the Single value 0 to the Int64 value 0.
272+
' Converted the Single value 9.113E-16 to the Int64 value 0.
273+
' Converted the Single value 103.919 to the Int64 value 104.
274+
' Converted the Single value 17834.191 to the Int64 value 17834.
275+
' 3.4028235E+38 is outside the range of the Int64 type.
276276
' </Snippet10>
277277
End Sub
278278

@@ -281,7 +281,7 @@ Module modMain
281281
Dim values() As String = { "One", "1.34e28", "-26.87", "-18", "-6.00", _
282282
" 0", "137", "1601.9", Int32.MaxValue.ToString() }
283283
Dim result As Long
284-
284+
285285
For Each value As String In values
286286
Try
287287
result = Convert.ToInt64(value)
@@ -292,8 +292,8 @@ Module modMain
292292
Catch e As FormatException
293293
Console.WriteLine("The {0} value '{1}' is not in a recognizable format.", _
294294
value.GetType().Name, value)
295-
End Try
296-
Next
295+
End Try
296+
Next
297297
' The example displays the following output:
298298
' The String value 'One' is not in a recognizable format.
299299
' The String value '1.34e28' is not in a recognizable format.
@@ -329,7 +329,7 @@ Module modMain
329329
' Converted the UInt16 value 65535 to the Int64 value 65535.
330330
' </Snippet12>
331331
End Sub
332-
332+
333333
Private Sub ConvertUInt32()
334334
' <Snippet13>
335335
Dim numbers() As UInteger = { UInt32.MinValue, 121, 340, UInt32.MaxValue }
@@ -347,12 +347,12 @@ Module modMain
347347
' Converted the UInt32 value 4,294,967,295 to the Int64 value 4,294,967,295.
348348
' </Snippet13>
349349
End Sub
350-
350+
351351
Private Sub ConvertUInt64
352352
' <Snippet14>
353353
Dim numbers() As ULong = { UInt64.MinValue, 121, 340, UInt64.MaxValue }
354354
Dim result As Long
355-
355+
356356
For Each number As ULong In numbers
357357
Try
358358
result = Convert.ToInt64(number)
@@ -369,7 +369,7 @@ Module modMain
369369
' Converted the UInt64 value 121 to the Int64 value 121.
370370
' Converted the UInt64 value 340 to the Int64 value 340.
371371
' The UInt64 value 18446744073709551615 is outside the range of the Int64 type.
372-
' </Snippet14>
372+
' </Snippet14>
373373
End Sub
374374
End Module
375375

0 commit comments

Comments
 (0)