Starting Index of Arrays in C# and VB.Net

后端 未结 3 939
既然无缘
既然无缘 2020-12-11 16:57

Have a look at the following code.,

C#

 string[] testString = new string[jobs.Count];

Equivalent VB.Net

3条回答
  •  春和景丽
    2020-12-11 17:36

    In C# the array has the number of elements you provide:

    string[] array = new string[2]; // will have two element [0] and [1]
    

    In VB.NET the array has the number of elements you provide, plus one (you specify the max index value):

    Dim array(2) As String // will have three elements (0), (1) and (2)
    

提交回复
热议问题