Now I will have a problem if I use:
Dim otrocarros As List(Of Car)
Instead of
Dim otrocarros As Cars
Then I will not have access to my Property OwnerName() located in my Cars
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 Juan = New With {.Edad = 24, .Color = "Verde"}
'Dim s As String
's.IsJmoa(1)
Dim crs As New Cars
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"})
crs.OwnerName = "Juan" 'OK!
Dim otrocarros As List(Of Car)
otrocarros = (From c In crs Where c.Color.StartsWith("R") Select
c).ToList()
'I cannot set the Owner Name
otrocarros.OwnerName = "Juan" 'X
For Each oc In otrocarros
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 Car
Private _color As String
Public Property Color() As String
Get
Return _color
End Get
Set(ByVal value As String)
_color = value
End Set
End Property
End Class
Juan M. OviedoFrom: [email protected]
To: [email protected]
Subject: RE: [DotNetDevelopment] Re: LINQ Error
Date: Thu, 11 Jun 2009 09:28:43 -0500
I see your change, now is working, thank you!
Dim otrocarros As List(Of Car)
otrocarros = (From c In crs Where c.Color.StartsWith("R") Select
c).ToList()
Juan M. Oviedo
Date: Thu, 11 Jun 2009 11:38:25 +0530
Subject: [DotNetDevelopment] Re: LINQ Error
From: [email protected]
To: [email protected]
Hi Juan
Try this code..........and enjoy
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 Cars
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 List(Of Car)
otrocarros = (From c In crs Where c.Color.StartsWith("R") Select
c).ToList()
For Each oc In otrocarros
Response.Write(oc.Color.ToString)
Next
End Sub
End Class
Public Class Cars
Inherits List(Of Car)
End Class
Public Class Car
Private _color As String
Public Property Color() As String
Get
Return _color
End Get
Set(ByVal value As String)
_color = value
End Set
End Property
End Class
Thanks!!!!