在VB.Net中使用lambda表达式会导致没有智能感知。这是VS2010的bug还是预期行为?请注意,C#中可以正常工作。
Return Array.TrueForAll(chequeColl, Function(x) x.Number <> "N") 'No intellisense Number does not appear
Return Array.TrueForAll(chequeColl, Function(x As MyClass) x.Number <> "N") 'Now casted intellisense appears
更新:这里有一个例子
Public Class Cheque
Public Property Id As String
Public Property Status As Byte
Public Property Amount As String
Public Property Number As String
End Class
Public Class ChequeCollection
Private chequeColl() As Cheque
Public Sub DoStuff()
Array.TrueForAll(chequeColl, Function(x As Cheque) x.Number = 1) 'x has to be cast as cheque for intellisense to appear
End Sub
End Class
List(Of T)
获得智能感知:Dim lst As List(Of Cheque): lst.TrueForAll(Function(x) x.Number = 1)
。对于这个问题,有人知道答案吗?+1。 - MarkJ