-
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
Open
StuartMosquera
wants to merge
4
commits into
dotnet:main
Choose a base branch
from
StuartMosquera:fix-example-readability-for-AddRange
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−121
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
snippets/csharp/System.Collections.Generic/ListT/.ctor/project.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
snippets/visualbasic/System.Collections.Generic/ListT/.ctor/project.vbproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
115 changes: 59 additions & 56 deletions
115
snippets/visualbasic/System.Collections.Generic/ListT/.ctor/source2.vb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,102 @@ | ||
' <Snippet1> | ||
Imports System.Collections.Generic | ||
|
||
Public Class Example | ||
Check failure on line 4 in snippets/visualbasic/System.Collections.Generic/ListT/.ctor/source2.vb
|
||
|
||
Public Shared Sub Main() | ||
|
||
Dim input() As String = { "Brachiosaurus", _ | ||
"Amargasaurus", _ | ||
"Mamenchisaurus" } | ||
|
||
Dim dinosaurs As New List(Of String)(input) | ||
Dim input() As String = { "Apple", _ | ||
"Banana", _ | ||
"Orange" } | ||
|
||
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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.