Assigning default value to an array

95se5m

Member
Joined
Nov 29, 2004
Messages
21
Location
NE Pennsylvania
Programming Experience
3-5
How do you assign a default value to an array when defining the array variable?

Eg. Dim arySomething as String() = ""

Obviously this does not work.

However in VB.NET 2005 beta 1 which I am using to make sure my apps will be complient with VB.NET 2005 when it is released, it states the following...

Warning 1 Variable 'arySomething' is used before it has been assigned a value. A null reference exception could result at runtime. C:\Development\SomeApp\Main\Modules\mController.vb 64 16

Any Thoughts? Or am I being a goof. I never thought to assign an array a default value till now so I never learned the way to do it.
 

95se5m

Member
Joined
Nov 29, 2004
Messages
21
Location
NE Pennsylvania
Programming Experience
3-5
Never mind... The answer is this.


dim arySomeArray as String() = {""}
this sets the default value of at least the first object in the array to nothing.
 
Top Bottom