Distinct and Skip using IEnumerable(Of XElement)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am trying to query by Distinct and then using the skip, but to do that (as I undersand) I have to use an IEnumerable(Of XElement) but this doesnt seam to be able to be "distincted"

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Form1_Load(<span style="color:Blue; ByVal sender <span style="color:Blue; As System.Object, _
<span style="color:Blue; ByVal e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.Load
<span style="color:Green; Dim songList As XElement = _
<span style="color:Green; XElement.Load("C:Jukeboxsongs.xml")
<span style="color:Blue; Dim songList <span style="color:Blue; As XElement = _
<SongList>
<Song>
<Info>
<Title>title 7</Title>
<Artist>artist 7</Artist>
</Info>
<Category>
<Genre>00<span style="color:Green; s</Genre>
<Genre>Pop</Genre>
</Category>
<Data>
</Data>
</Song>

<Song>
<Info>
<Title>title 9</Title>
<Artist>artist 9</Artist>
</Info>
<Category>
<Genre>90<span style="color:Green; s</Genre>
<Genre>Pop</Genre>
</Category>
<Data>
</Data>
</Song>
<Song>
<Info>
<Title>title 10</Title>
<Artist>artist 10</Artist>
</Info>
<Category>
<Genre>80<span style="color:Green; s</Genre>
<Genre>Rock</Genre>
</Category>
<Data>
</Data>
</Song>
</SongList>

<span style="color:Blue; Dim genres = <span style="color:Blue; From genreElement _
<span style="color:Blue; In songList.<Song>.<Category>.<Genre> _
<span style="color:Blue; Select genreElement.Value _
<span style="color:Blue; Distinct

<span style="color:Blue; For <span style="color:Blue; Each genre <span style="color:Blue; In genres
<span style="color:Green;
<span style="color:Blue; Next

MsgBox(genres.<span style="color:Blue; Skip(0).Value & genres.<span style="color:Blue; Skip(1).Value)

[/code]

How can I enumerate the result?
Thnaks :)
Andy :)



<hr class="sig Currently working on my first VB Project - A music Player - until i am old enough to take programing at school :) Please be kind as I am only learning and I learn best by dissecting something, rebuilding it and asking questions :)

View the full article
 
Back
Top