Hello everyone, I have created the following subroutine that creates a collection and each element of the collection is a stack. I would like to mention, that each stack element is class object with some properties that I want to access.
How then can I access an element-item of a stack through the collection???? Any suggestions please??? Any help will be much appreciated. Thank you so much in advanced.
Public Sub CreateInitialStacks()
Dim UsrCheckerCollection As System.Collections.ArrayList = New System.Collections.ArrayList
Dim UsrStack As Stack = New Stack
Dim cnt As Integer = 0
For i = 0 To UsrCheckers.Length - 2
If i < UsrCheckers.Length - 2 Then
If UsrCheckers(i).Position = UsrCheckers(i + 1).Position Then
If cnt = 0 Then UsrStack.Push(UsrCheckers(i))
UsrStack.Push(UsrCheckers(i + 1))
cnt = cnt + 1
Else
UsrCheckerCollection.Add(UsrStack)
UsrStack.Clear()
cnt = 0
End If
ElseIf i = UsrCheckers.Length - 2 Then
UsrCheckerCollection.Add(UsrStack)
UsrStack.Clear()
cnt = 0
End If
Next
End Sub
How then can I access an element-item of a stack through the collection???? Any suggestions please??? Any help will be much appreciated. Thank you so much in advanced.
Public Sub CreateInitialStacks()
Dim UsrCheckerCollection As System.Collections.ArrayList = New System.Collections.ArrayList
Dim UsrStack As Stack = New Stack
Dim cnt As Integer = 0
For i = 0 To UsrCheckers.Length - 2
If i < UsrCheckers.Length - 2 Then
If UsrCheckers(i).Position = UsrCheckers(i + 1).Position Then
If cnt = 0 Then UsrStack.Push(UsrCheckers(i))
UsrStack.Push(UsrCheckers(i + 1))
cnt = cnt + 1
Else
UsrCheckerCollection.Add(UsrStack)
UsrStack.Clear()
cnt = 0
End If
ElseIf i = UsrCheckers.Length - 2 Then
UsrCheckerCollection.Add(UsrStack)
UsrStack.Clear()
cnt = 0
End If
Next
End Sub