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

C# Equivalent to VB Arrays

Unsized Array

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

Sized Array

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

Access Array Element

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

Jagged Array

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

Rectangular Array

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

Resizing Array

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

Initializing Array

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

Empty Array

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


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

Additional resource: VB.NET and C# Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.