Public Class MyList
Inherits List(Of MyObject)
Public ReadOnly Property SelectedCount() As Integer
Get
Return Me.Count(Function(obj) obj.IsS
You can cast Me to IEnumerable(Of MyObject):
Return DirectCast(Me, IEnumerable(Of MyObject)).Count(Function(obj) obj.IsSelected)
Or use Enumerable.Count() method directly:
Return Enumerable.Count(Me, Function(obj) obj.IsSelected)
Extension Methods are transformed by compiler into direct static (shared in VB) methods calls, so there is no difference.
Have no idea, really.
Casting to underlying type does not change the object itself, so there is no performance penalty (unless boxing is involved, what is not a case here).
C# does not allow properties with parameters and it requires properties to be called without (), so yes, it's better in situations like this one.
In VB.NET both Me.Count() and Me.Count refer to Count property of List(Of T). In C# this.Count would refer to property and this.Count() would refer the extension method (because of parentheses).