Reputation: 7320
is there a way i can do like this in vb.net
dim idx = -1
dim a = array(idx = idx + 1)
dim b = array(idx = idx + 1)
dim c = array(idx = idx + 1)
dim d = array(idx = idx + 1)
what i want is that idx keeps incrementing after each line, without incrementing it on a seperate line.
Thank you
Upvotes: 1
Views: 941
Reputation: 81610
I don't think VB.Net has anything like that, but you can make an extension to get close to it:
Imports System.Runtime.CompilerServices
Public Module Module1
<Extension()> _
Public Function UpIndex(ByRef value As Integer) As Integer
value += 1
return value
End Function
End Module
Note the use of ByRef
in the arguments.
Then your call would look like this:
Dim a = array(idx.UpIndex)
Dim b = array(idx.UpIndex)
Upvotes: 3