DevPinoy.org
A Filipino Developers Community

>>> First two to make 3 wins! <<<

VB.NET's Array Size -- ugh!
Do you have any idea why the following test case fails?

Imports NUnit.Framework

 

<TestFixture()> _

Public Class ArrayTests

 

    <Test()> _

    Public Sub ArraySize()

        Dim myArray(5) As Integer

        Assert.AreEqual(5, myArray.Length)

    End Sub

End Class


The reason is one of the differences between vb.net and c# that i hate.

Posted 09-26-2006 7:30 PM by jokiz
Filed under: , ,

Comments

dehran ph wrote re: VB.NET's Array Size -- ugh!
on 09-26-2006 4:20 AM

VB.NEt starts with 1 and C# starts with 0;

jokiz wrote re: VB.NET's Array Size -- ugh!
on 09-26-2006 4:35 AM

actually, all vb

Ravi wrote re: VB.NET's Array Size -- ugh!
on 10-26-2006 2:06 PM
In VB.NET the parameter passed while creating an array is not the size but indeed it is the last index of the array. So, the lenght of hte array will be last index (the value you have passed while creating an array) plus 1. Hope this helps you.

Copyright DevPinoy 2005-2008