Why List(Of T) doesn't have Count()?

前端 未结 4 940
予麋鹿
予麋鹿 2021-02-15 22:16
Public Class MyList
    Inherits List(Of MyObject)

    Public ReadOnly Property SelectedCount() As Integer
        Get
            Return Me.Count(Function(obj) obj.IsS         


        
4条回答
  •  死守一世寂寞
    2021-02-15 22:51

    Call the method without the extension method syntax:

    Public Class MyList
        Inherits List(Of MyObject)
    
        Public ReadOnly Property SelectedCount() As Integer
            Get
                Return Enumerable.Count(Me, Function(obj) obj.IsSelected)
            End Get
        End Property
    End Class
    

    Make sure you have added an import to System.Linq.

提交回复
热议问题