• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

VB Equivalent to C# Arrays

Unsized Array

C# VB.NET
int[] myArray = null; Dim myArray() As Integer

Sized Array

C# VB.NET
int[] myArray = new int[2]; Dim myArray(1) As Integer

Access Array Element

C# VB.NET
x = myArray[0]; x = myArray(0)

Jagged Array

C# VB.NET
int[][] myArray = new int[2][]; Dim myArray(1)() As Integer

Rectangular Array

C# VB.NET
int[,] myArray = new int[2, 3]; Dim myArray(1, 2) As Integer

Resizing Array

C# VB.NET
System.Array.Resize(ref myArray, newSize + 1);
myArray = new foo[newSize + 1];
ReDim Preserve myArray(newSize)
ReDim myArray(newSize)

Initializing Array

C# VB.NET
myArray = new int[2] {1, 2}; myArray = New Integer(1) {1,2}

Empty Array

C# VB.NET
string[] myArray = new string[0]; Dim myArray As String() = New String() {}


Use Instant VB to convert from C# to VB.NET.     

Additional resource: VB.NET and C# Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.