Skip to content

Commit

Permalink
Changes to VB and C++ code to parallel C# code (#3217)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Petrusha committed Sep 27, 2017
1 parent b21ad02 commit 87b9d6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
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

0 comments on commit 87b9d6e

Please sign in to comment.