LINQ Casting

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All, I have a name.xml
<pre class="prettyprint" style="font-size:12px <Root>
<Names>
<Name>John</Name>
</Names>
</Root>[/code]
A name class
<pre class="prettyprint" style="font-size:12px Public Class Names
Private _name As String
Public Property name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property

End Class[/code]
I wish to return the result from linq to xml from the code below into a list. I am getting "Unable to cast object of type System.Collections.Generic.List`1[LINQ.join] to type LINQ.join." Need some help on this. Thanks!
<pre class="prettyprint" style="font-size:12px Dim NameList As IEnumerable(Of Names) = (From list In XElement.Load("Name.xml").Elements("Names") Select New join With {.name = list.Element("name")}).ToList
Dim list As IList(Of Names) = Nothing
list.add(Namelist)
[/code]
<br/>

View the full article
 
Back
Top