-
Notifications
You must be signed in to change notification settings - Fork 1.6k
make AddRange method example more readable #11910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
84bfaa4
a5f7898
a467cda
bde57b3
672d3eb
147ea5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
' <Snippet1> | ||
Imports System.Collections.Generic | ||
|
||
Public Class Example | ||
Partial Public Class Example | ||
|
||
|
||
Public Shared Sub Main() | ||
|
||
|
@@ -63,4 +63,4 @@ End Class | |
'Amargasaurus | ||
'Coelophysis | ||
'Deinonychus | ||
' </Snippet1> | ||
' </Snippet1> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
' <Snippet1> | ||
Imports System.Collections.Generic | ||
|
||
Public Class Example | ||
Partial Public Class Example | ||
|
||
Public Shared Sub Main() | ||
Public Shared Sub ShowDinos() | ||
|
||
' <snippet2> | ||
Dim dinosaurs As New List(Of String) | ||
|
||
|
@@ -99,4 +99,4 @@ End Class | |
'Clear() | ||
'Capacity: 5 | ||
'Count: 0 | ||
' </Snippet1> | ||
' </Snippet1> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,98 @@ | ||
' <Snippet1> | ||
Imports System.Collections.Generic | ||
|
||
Public Class Example | ||
Partial Public Class Example | ||
Public Shared Sub ShowFruits() | ||
|
||
Public Shared Sub Main() | ||
Dim input() As String = { "Apple", _ | ||
"Banana", _ | ||
"Orange" } | ||
|
||
Dim input() As String = { "Brachiosaurus", _ | ||
"Amargasaurus", _ | ||
"Mamenchisaurus" } | ||
|
||
Dim dinosaurs As New List(Of String)(input) | ||
|
||
Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity) | ||
Dim fruits As New List(Of String)(input) | ||
|
||
Console.WriteLine(vbLf & "Capacity: {0}", fruits.Capacity) | ||
Console.WriteLine() | ||
For Each dinosaur As String In dinosaurs | ||
Console.WriteLine(dinosaur) | ||
|
||
For Each fruit As String In fruits | ||
Console.WriteLine(fruit) | ||
Next | ||
|
||
Console.WriteLine(vbLf & "AddRange(dinosaurs)") | ||
dinosaurs.AddRange(dinosaurs) | ||
Console.WriteLine(vbLf & "AddRange(fruits)") | ||
fruits.AddRange(fruits) | ||
|
||
Console.WriteLine() | ||
For Each dinosaur As String In dinosaurs | ||
Console.WriteLine(dinosaur) | ||
For Each fruit As String In fruits | ||
Console.WriteLine(fruit) | ||
Next | ||
|
||
Console.WriteLine(vbLf & "RemoveRange(2, 2)") | ||
dinosaurs.RemoveRange(2, 2) | ||
fruits.RemoveRange(2, 2) | ||
|
||
Console.WriteLine() | ||
For Each dinosaur As String In dinosaurs | ||
Console.WriteLine(dinosaur) | ||
For Each fruit As String In fruits | ||
Console.WriteLine(fruit) | ||
Next | ||
|
||
input = New String() { "Tyrannosaurus", _ | ||
"Deinonychus", _ | ||
"Velociraptor" } | ||
input = New String() { "Mango", _ | ||
"Pineapple", _ | ||
"Watermelon" } | ||
|
||
Console.WriteLine(vbLf & "InsertRange(3, input)") | ||
dinosaurs.InsertRange(3, input) | ||
fruits.InsertRange(3, input) | ||
|
||
Console.WriteLine() | ||
For Each dinosaur As String In dinosaurs | ||
Console.WriteLine(dinosaur) | ||
For Each fruit As String In fruits | ||
Console.WriteLine(fruit) | ||
Next | ||
|
||
Console.WriteLine(vbLf & "output = dinosaurs.GetRange(2, 3).ToArray") | ||
Dim output() As String = dinosaurs.GetRange(2, 3).ToArray() | ||
Console.WriteLine(vbLf & "output = fruits.GetRange(2, 3).ToArray") | ||
Dim output() As String = fruits.GetRange(2, 3).ToArray() | ||
|
||
Console.WriteLine() | ||
For Each dinosaur As String In output | ||
Console.WriteLine(dinosaur) | ||
For Each fruit As String In output | ||
Console.WriteLine(fruit) | ||
Next | ||
|
||
End Sub | ||
End Class | ||
|
||
' This code example produces the following output: | ||
' | ||
'Capacity: 3 | ||
' Capacity: 3 | ||
' | ||
'Brachiosaurus | ||
'Amargasaurus | ||
'Mamenchisaurus | ||
' Apple | ||
' Banana | ||
' Orange | ||
' | ||
'AddRange(dinosaurs) | ||
' AddRange(fruits) | ||
' | ||
'Brachiosaurus | ||
'Amargasaurus | ||
'Mamenchisaurus | ||
'Brachiosaurus | ||
'Amargasaurus | ||
'Mamenchisaurus | ||
' Apple | ||
' Banana | ||
' Orange | ||
' Apple | ||
' Banana | ||
' Orange | ||
' | ||
'RemoveRange(2, 2) | ||
' RemoveRange(2, 2) | ||
' | ||
'Brachiosaurus | ||
'Amargasaurus | ||
'Amargasaurus | ||
'Mamenchisaurus | ||
' Apple | ||
' Banana | ||
' Banana | ||
' Orange | ||
' | ||
'InsertRange(3, input) | ||
' InsertRange(3, input) | ||
' | ||
'Brachiosaurus | ||
'Amargasaurus | ||
'Amargasaurus | ||
'Tyrannosaurus | ||
'Deinonychus | ||
'Velociraptor | ||
'Mamenchisaurus | ||
' Apple | ||
' Banana | ||
' Banana | ||
' Mango | ||
' Pineapple | ||
' Watermelon | ||
' Orange | ||
' | ||
'output = dinosaurs.GetRange(2, 3).ToArray | ||
' output = fruits.GetRange(2, 3).ToArray | ||
' | ||
'Amargasaurus | ||
'Tyrannosaurus | ||
'Deinonychus | ||
' </Snippet1> | ||
' Banana | ||
' Mango | ||
' Pineapple | ||
' </Snippet1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use top-level statements here