Skip to content
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

Changes to VB and C++ code to parallel C# code #3217

Merged
merged 1 commit into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Changes to VB and C++ code to parallel C# code
  • Loading branch information
Ron Petrusha committed Sep 25, 2017
commit dafcc5f2fd8b1d8c2dcfdab1fd1a8ff64e07697d
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using namespace System;


using namespace System;
using namespace System::Text;

ref class Example
{
Expand Down Expand Up @@ -30,18 +29,19 @@ ref class Example
// <Snippet33>
array<int>^ years = { 2013, 2014, 2015 };
array<int>^ population = { 1025632, 1105967, 1148203 };
String^ s = String::Format("{0,6} {1,15}\n\n", "Year", "Population");
StringBuiler^ sb = gcnew StringBuilder();
sb->Append(String::Format("{0,6} {1,15}\n\n", "Year", "Population"));
for(int index = 0; index < years->Length; index++)
s += String::Format("{0,6} {1,15:N0}\n",
years[index], population[index]);
sb->AppendFormat("{0,6} {1,15:N0}\n",
years[index], population[index]);
// Result:
// Year Population
//
// 2013 1,025,632
// 2014 1,105,967
// 2015 1,148,203
// </Snippet33>
Console::WriteLine(s);
Console::WriteLine(sb);
}

static void Snippet34()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
' Visual Basic .NET Document
' Visual Basic .NET Document
Option Strict On

Imports System.Text

Module Example
Public Sub Main()
' <Snippet30>
Expand Down Expand Up @@ -38,11 +40,12 @@ Module Example
' <Snippet33>
Dim years() As Integer = { 2013, 2014, 2015 }
Dim population() As Integer = { 1025632, 1105967, 1148203 }
Dim s As String = String.Format("{0,6} {1,15}{2}{2}",
"Year", "Population", vbCrLf)
Dim sb As New StringBuilder()
sb.Append(String.Format("{0,6} {1,15}{2}{2}",
"Year", "Population", vbCrLf))
For index As Integer = 0 To years.Length - 1
s += String.Format("{0,6} {1,15:N0}{2}",
years(index), population(index), vbCrLf)
sb.AppendFormat("{0,6} {1,15:N0}{2}",
years(index), population(index), vbCrLf)
Next
' Result:
' Year Population
Expand All @@ -51,7 +54,7 @@ Module Example
' 2014 1,105,967
' 2015 1,148,203
' </Snippet33>
Console.WriteLine(s)
Console.WriteLine(sb)
End Sub

Private Sub Snippet34()
Expand Down