Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lambda with vb.net complicated structures doesn't produce or appear result values.

Status
Not open for further replies.

WomanPro

Programmer
Nov 1, 2012
180
0
0
GR
Well, I am trying to get experience with lambda expressions and complicated types and I need you help. I am very new at LINQ and at complicated classes. Let's suppose the following code.
I have the structure GatesPositions with 2 fields a stack and an byte variable, I declare an array of this type which is seriousArr, I fill it with values, and the what I want to do is to get in a result the elements that sutisfy specific creteria where the intValue is greater than 20. In step by step debugging I see at Result.view values false, false, true, true and I understand that the last 2 elements sutisfy the condition, but I don't know what I' m missing to appear the results with these instuction: Dim action As Action(Of GatesPositions) = Sub(x) Console.WriteLine(x.intValue)
I don't see anything in the results, is there a way to appear the results in the console and to be able to access each element value of results? I would appreciate if anybody will explain me about. Any help will be much appreciated as soon as possible please.

Code:
Module Module1
    Public Structure GatesPositions
        Public intValue As Byte
        Public stack As Stack
    End Structure
    Sub Main()
        Dim seriousArr(3) As GatesPositions
        Dim y As Integer = 0
        For i As Byte = 0 To seriousArr.Count - 1
            seriousArr(i) = New GatesPositions
            seriousArr(i).intValue = y + 10
            y = seriousArr(i).intValue
            seriousArr(i).stack = New Stack
            If i = 0 Then FillStackWithValues(seriousArr(i).stack)
            If i > 0 Then
                FillStackWithValues(seriousArr(i).stack)
                For j As Byte = 1 To i
                    seriousArr(i).stack.Push(seriousArr(i).stack.Peek + 10)
                Next
            End If
        Next

        Dim result = seriousArr.Select(Function(x) x.intValue > 20)

        Dim action As Action(Of GatesPositions) = Sub(x) Console.WriteLine(x.intValue)
        Console.Read()
    End Sub
    Public Sub FillStackWithValues(ByRef st As Stack)
        st.Push(50)
        st.Push(60)
        st.Push(70)
    End Sub
End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top