Do Cars class have to inherit List(of Car) ?
If not use this class
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim crs As New List(Of Car)
crs.Add(New Car() With {.Color = "Rojo"})
crs.Add(New Car() With {.Color = "Verde"})
crs.Add(New Car() With {.Color = "Rojo"})
crs.Add(New Car() With {.Color = "Azul"})
Dim otrocarros As New Cars
otrocarros.Cars = (From c In crs Where c.Color.StartsWith("R")
Select c).ToList()
otrocarros.OwnerName = "Juan"
For Each oc In otrocarros.Cars
Response.Write(oc.Color.ToString)
Next
End Sub
End Class
Public Class Cars
Inherits List(Of Car)
Private _OwnerName As String
Public Property OwnerName() As String
Get
Return _OwnerName
End Get
Set(ByVal value As String)
_OwnerName = value
End Set
End Property
End Class
Public Class Cars
Private _OwnerName As String
Public Property OwnerName() As String
Get
Return _OwnerName
End Get
Set(ByVal value As String)
_OwnerName = value
End Set
End Property
Private _cars As List(Of Car)
Public Property Cars() As List(Of Car)
Get
Return _cars
End Get
Set(ByVal value As List(Of Car))
_cars = value
End Set
End Property
End Class