views:

22

answers:

1

I'm having issues with returning a list of strings of the .Value of a Linq query:

    Dim details = <Details>
                      <Vector size="5">
                          <Item>Syntactic Structures</Item>
                          <Item>Introduction</Item>
                          <Item>The Independence of Grammar</Item>
                          <Item>An Elementary Linguistic Theory</Item>
                          <Item>Phrase Structure</Item>
                      </Vector>
                  </Details>
    Dim chapterTitles = details.<Vector>.<Item>.Skip(1).Take(4)

Is correct in that it returns the list of XElements I want (items 1 - 4, base 0), but I really just need a list of strings for the .Value of those XElements. Maybe I'm just dense here, but anything I've tried in the chapterTitles query isn't working (appending with .ToList.ToString, etc.). details.<Vector>.<Item>.Skip(1).Take(4).Value just returns the first XElement's value.

Any thoughts?

+3  A: 

You'll need to do a Select to transform the results from XElements to strings.

Dim chapterTitles = details.<Vector>.<Item>.Skip(1).Take(4).Select(Function(item) item.Value)

or

Dim chapterTitles = From item In details.<Vector>.<Item>.Skip(1).Take(4) _
                    Select item.Value
bdukes
Ugh, how could I be so dense! Works like a charm, thank you! Needs 10 more minues to accept, so I'll do it then.
Otaku