.Value 对于Linq查询:
.Value
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)
是正确的,因为它返回我想要的元素列表(项目1-4,基数0),但是我真的只需要一个字符串列表就可以了 这些元素。也许我只是有点迷糊,但我以前试过的任何东西 chapterTitles 查询不起作用(追加了。ToList.ToString目录等)。 details.<Vector>.<Item>.Skip(1).Take(4).Value 只返回第一个XElement的值。
chapterTitles
details.<Vector>.<Item>.Skip(1).Take(4).Value
有什么想法吗?
Select XElement s到 string s。
Select
XElement
string
Dim chapterTitles = details.<Vector>.<Item>.Skip(1).Take(4).Select(Function(item) item.Value)
或
Dim chapterTitles = From item In details.<Vector>.<Item>.Skip(1).Take(4) _ Select item.Value