.NET Replacement for VB6's 'Array' keyword?
In VB6, it was easy to pass a array of a certain type (ok, technically it was a array of variants) into a function as follows:
Code:
x = Foo(Array(2,3,5,7)) 'Array of integers
I know that in VB.NET, I can accomplish the same thing via code like this:
Code:
Dim bar(4) as Integer
bar(0) = 2
bar(1) = 3
bar(2) = 5
bar(3) = 7
x = Foo(bar)
However, this is a lot of extra code to express the same thing. Is there a way in VB.NET to inline the array definition in a single line (similar to what the VB6 code does)?
Many thanks!
- Kevin
Re: .NET Replacement for VB6's 'Array' keyword?
Code:
x = Foo( New Integer() { 2 , 3 , 5 , 7 } )
Re: .NET Replacement for VB6's 'Array' keyword?
:blush: That was easy! Thanks.
I deal with C++ (ISO, not managed or C++/CLI) 98% of the time and have to dabble with VB.NET every once in a while.
Thanks again!