Declaring a array
-
Hello every one, I am working on a Vb.net 2005 application. I came across two ways to declare a array, i just wanted to know is there any difference between them
Dim iTestArray() As Integer
and
Dim iTestArray As Integer()
Regards Nishkarsh
-
Hello every one, I am working on a Vb.net 2005 application. I came across two ways to declare a array, i just wanted to know is there any difference between them
Dim iTestArray() As Integer
and
Dim iTestArray As Integer()
Regards Nishkarsh
No, there isn't.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hello every one, I am working on a Vb.net 2005 application. I came across two ways to declare a array, i just wanted to know is there any difference between them
Dim iTestArray() As Integer
and
Dim iTestArray As Integer()
Regards Nishkarsh
First of all, an
Array
isn't the same as anInteger
. AnInteger
can't hold multiple values. To dim an array you should use the following:Dim ArrayName As Array
Or:
Dim ArrayListName As New ArrayList
The difference between these two is (again, as far as I know :rolleyes: ) that the size of the ArrayList is dynamically increased when needed, and that the (regular) Array doens't do this. Cheers, Zaegra
Motivation is the key to software development.
-
First of all, an
Array
isn't the same as anInteger
. AnInteger
can't hold multiple values. To dim an array you should use the following:Dim ArrayName As Array
Or:
Dim ArrayListName As New ArrayList
The difference between these two is (again, as far as I know :rolleyes: ) that the size of the ArrayList is dynamically increased when needed, and that the (regular) Array doens't do this. Cheers, Zaegra
Motivation is the key to software development.
Nishkarsh's original array declarations are absolutely correct. Your method of declaring it as 'Array' (System.Array) is generally the wrong thing to do. Declaring a variable of type 'Array' is a special purpose technique that is rarely required.
David Anton http://www.tangiblesoftwaresolutions.com Convert VB to C#, C++, or Java Convert C# to VB, C++, or Java Convert C++ to C#, VB, or Java Convert Java to C#, C++, or VB
-
Nishkarsh's original array declarations are absolutely correct. Your method of declaring it as 'Array' (System.Array) is generally the wrong thing to do. Declaring a variable of type 'Array' is a special purpose technique that is rarely required.
David Anton http://www.tangiblesoftwaresolutions.com Convert VB to C#, C++, or Java Convert C# to VB, C++, or Java Convert C++ to C#, VB, or Java Convert Java to C#, C++, or VB
-
Then please explain to me how I can store multiple values in an Integer? Because as far as I know an integer is just a number? :wtf:
Motivation is the key to software development.
You can't store multiple values in an Integer. This is just the syntax you use when declaring arrays. i.e., Dim i() As Integer or Dim i As Integer() The parenthesis pair after either the identifier or the type indicates that it's an array of Integer, not a single Integer.
David Anton http://www.tangiblesoftwaresolutions.com Convert VB to C#, C++, or Java Convert C# to VB, C++, or Java Convert C++ to C#, VB, or Java Convert Java to C#, C++, or VB
-
Then please explain to me how I can store multiple values in an Integer? Because as far as I know an integer is just a number? :wtf:
Motivation is the key to software development.
Zaegra wrote:
how I can store multiple values
Dim MyMixedValueArray() As Object
or
Dim MyMixedValueArray As Object()
My advice is free, and you may get what you paid for.
-
Zaegra wrote:
how I can store multiple values
Dim MyMixedValueArray() As Object
or
Dim MyMixedValueArray As Object()
My advice is free, and you may get what you paid for.