我不是VB的粉絲。任何人都可以幫助我在c#中創建這段代碼嗎?什麼是VB Linq中Aggregate關鍵字的C#等價物?
Public ReadOnly Property HasErrors() As Boolean
Get
Return (Aggregate o In Me _
Let errObj = TryCast(o, IDataErrorInfo) _
Where If(errObj IsNot Nothing, errObj.Error <> Nothing, False) _
Into Count()) > 0
End Get
End Property
更新
Public MustInherit Class MyBaseCollection(Of T)
Inherits ObservableCollection(Of T)
Public ReadOnly Property HasErrors() As Boolean
Get
Return (Aggregate o In Me _
Let errObj = TryCast(o, IDataErrorInfo) _
Where If(errObj IsNot Nothing, errObj.Error <> Nothing, False) _
Into Count()) > 0
End Get
End Property
Sub New(ByVal query As IEnumerable(Of T), ByVal context As OMSEntities)
MyBase.New(query)
End Sub
End Class
我嘗試使用在線代碼轉換它來轉換。但是我最終得到了未編譯的代碼。 – sovantha