Instance members and 'Me' cannot be used in a query expression

A LINQ query in a Structure includes a reference to Me or to an instance member of the structure. References to Me or instance members are not allowed in query expressions within a Structure.

Error ID: BC36535

To correct this error

  • Create a copy of the instance member or the value returned by the reference to Me and use the copy in the query expression, as shown in the following example.

    Structure SampleStructure
        Public SearchValue As Integer
    
        Public Sub SetSearchValue(ByVal number As Integer)
          SearchValue = number
        End Sub
    
        Public Sub GetData()
            Dim sv = SearchValue
            Dim SampleData = New Integer() {1, 2, 3, 4}
            Dim query = From number In SampleData _
                        Where number < sv
        End Sub
    End Structure
    

See Also

Concepts

Introduction to LINQ in Visual Basic

Reference

Me

Structure (Visual Basic)

Other Resources

LINQ in Visual Basic