Skip to content

Commit 6396cf4

Browse files
committed
fix snippet
1 parent 9c5c177 commit 6396cf4

File tree

7 files changed

+33
-27
lines changed

7 files changed

+33
-27
lines changed

snippets/visualbasic/System/String/Join/join1.vb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,28 @@ Module Example
99
Console.WriteLine("Primes less than {0}:", maxPrime)
1010
Console.WriteLine(" {0}", String.Join(" ", primes))
1111
End Sub
12-
12+
1313
Private Function GetPrimes(maxPrime As Integer) As Integer()
1414
Dim values As Array = Array.CreateInstance(GetType(Integer), _
15-
New Integer() { maxPrime - 1}, New Integer(){ 2 })
15+
New Integer() { maxPrime - 1}, New Integer(){ 2 })
1616
' Use Sieve of Eratosthenes to determine prime numbers.
1717
For ctr As Integer = values.GetLowerBound(0) To _
1818
CInt(Math.Ceiling(Math.Sqrt(values.GetUpperBound(0))))
1919
If CInt(values.GetValue(ctr)) = 1 Then Continue For
20-
20+
2121
For multiplier As Integer = ctr To maxPrime \ 2
2222
If ctr * multiplier <= maxPrime Then values.SetValue(1, ctr * multiplier)
23-
Next
24-
Next
25-
23+
Next
24+
Next
25+
2626
Dim primes As New System.Collections.Generic.List(Of Integer)
2727
For ctr As Integer = values.GetLowerBound(0) To values.GetUpperBound(0)
2828
If CInt(values.GetValue(ctr)) = 0 Then primes.Add(ctr)
29-
Next
29+
Next
3030
Return primes.ToArray()
31-
End Function
31+
End Function
3232
End Module
33+
3334
' The example displays the following output:
3435
' Primes less than 100:
3536
' 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

snippets/visualbasic/System/String/Join/join2.vb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Class Sample
1111
Console.WriteLine("String.Join(sep, val, 1, 2) = '{0}'", result)
1212
End Sub
1313
End Class
14+
1415
'This example displays the following output:
1516
' sep = ', '
1617
' val() = {'apple' 'orange' 'grape' 'pear'}

snippets/visualbasic/System/String/Join/join3.vb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,28 @@ Module Example
1111
Console.WriteLine("Primes less than {0}:", maxPrime)
1212
Console.WriteLine(" {0}", String.Join(" ", primes))
1313
End Sub
14-
14+
1515
Private Function GetPrimes(maxPrime As Integer) As List(Of String)
1616
Dim values As Array = Array.CreateInstance(GetType(Integer), _
17-
New Integer() { maxPrime - 1}, New Integer(){ 2 })
17+
New Integer() { maxPrime - 1}, New Integer(){ 2 })
1818
' Use Sieve of Eratosthenes to determine prime numbers.
1919
For ctr As Integer = values.GetLowerBound(0) To _
2020
CInt(Math.Ceiling(Math.Sqrt(values.GetUpperBound(0))))
2121
If CInt(values.GetValue(ctr)) = 1 Then Continue For
22-
22+
2323
For multiplier As Integer = ctr To maxPrime \ 2
2424
If ctr * multiplier <= maxPrime Then values.SetValue(1, ctr * multiplier)
25-
Next
26-
Next
27-
25+
Next
26+
Next
27+
2828
Dim primes As New List(Of String)
2929
For ctr As Integer = values.GetLowerBound(0) To values.GetUpperBound(0)
3030
If CInt(values.GetValue(ctr)) = 0 Then primes.Add(ctr.ToString())
31-
Next
31+
Next
3232
Return primes
33-
End Function
33+
End Function
3434
End Module
35+
3536
' The example displays the following output:
3637
' Primes less than 100:
3738
' 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

snippets/visualbasic/System/String/Join/join4.vb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ Module modMain
1010
Public Sub Main()
1111
Dim output As String = String.Join(" ", GetAlphabet(True).Where(Function(letter) _
1212
letter >= "M"))
13-
14-
Console.WriteLine(output)
13+
14+
Console.WriteLine(output)
1515
End Sub
16-
16+
1717
Private Function GetAlphabet(upper As Boolean) As List(Of String)
1818
Dim alphabet As New List(Of String)
1919
Dim charValue As Integer = CInt(IIf(upper, 65, 97))
2020
For ctr As Integer = 0 To 25
2121
alphabet.Add(ChrW(charValue + ctr).ToString())
2222
Next
23-
Return alphabet
23+
Return alphabet
2424
End Function
2525
End Module
26+
2627
' The example displays the following output:
2728
' M N O P Q R S T U V W X Y Z
2829
' </Snippet4>

snippets/visualbasic/System/String/Join/join5.vb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ Imports System.Collections.Generic
88
Public Class Animal
99
Public Kind As String
1010
Public Order As String
11-
11+
1212
Public Sub New(kind As String, order As String)
1313
Me.Kind = kind
1414
Me.Order = order
1515
End Sub
16-
16+
1717
Public Overrides Function ToString() As String
1818
Return Me.Kind
1919
End Function
@@ -24,12 +24,13 @@ Module Example
2424
Dim animals As New List(Of Animal)
2525
animals.Add(New Animal("Squirrel", "Rodent"))
2626
animals.Add(New Animal("Gray Wolf", "Carnivora"))
27-
animals.Add(New Animal("Capybara", "Rodent"))
27+
animals.Add(New Animal("Capybara", "Rodent"))
2828
Dim output As String = String.Join(" ", animals.Where(Function(animal) _
2929
animal.Order = "Rodent"))
30-
Console.WriteLine(output)
30+
Console.WriteLine(output)
3131
End Sub
3232
End Module
33+
3334
' The example displays the following output:
3435
' Squirrel Capybara
3536
' </Snippet5>

snippets/visualbasic/System/String/Join/join6.vb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
' Visual Basic .NET Document
22
Option Strict On
33

4-
' <Snippet2>
4+
' <Snippet1>
55
Imports System.Collections.Generic
66

77
Module Example
@@ -32,7 +32,8 @@ Module Example
3232
Return primes
3333
End Function
3434
End Module
35+
3536
' The example displays the following output:
3637
' Primes less than 100:
3738
' 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
38-
' </Snippet2>
39+
' </Snippet1>

xml/System/String.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9579,7 +9579,7 @@ The following example uses the Sieve of Eratosthenes algorithm to calculate the
95799579

95809580
:::code language="csharp" source="~/snippets/csharp/System/String/Join/join6.cs" interactive="try-dotnet" id="Snippet2":::
95819581
:::code language="fsharp" source="~/snippets/fsharp/System/String/Join/join6.fs" id="Snippet2":::
9582-
:::code language="vb" source="~/snippets/visualbasic/System/String/Join/join2.vb" id="Snippet2":::
9582+
:::code language="vb" source="~/snippets/visualbasic/System/String/Join/join6.vb" id="Snippet1":::
95839583

95849584
]]></format>
95859585
</remarks>

0 commit comments

Comments
 (0)