Why does this extension:
<Extension()> _
Public Function GetLastItem(ByVal l As List(Of Object)) As Object
Return l(l.Count - 1)
End Function
Work for instance of type List(of Object) but not for instance of type List(Of List(Of Object))?
Object is the most generic type in .net so List(of Object) is an Object and the extension should work?
Because a
List(Of List(Of Object))isn’t anObject.Rewrite your extension like this:\
In fact, this is even more general:
Of course, you should just use Linq: