Have a look at the following code.,
C#
string[] testString = new string[jobs.Count];
Equivalent VB.Net
Dim testString() As String = New String(jobs.Count - 1) {}
Why it is taking 'jobs.Count - 1' instead 'jobs.Count' in vb.net while creating new arrays?
In VB.NET the number in the array declaration means "max index", but in C# it means "number of elements"
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With