我有這樣Visual Basic中的LINQ to XML不能選擇對象
var books = System.Xml.Linq.XDocument.Load(_filename).Root.Elements("Book").Select(
x => new Book(
(string)x.Element("Title"),
(string)x.Element("Author"),
(string)x.Element("Publisher"),
(string)x.Element("ISBN")));
return books;
我把它轉換成一個VB C#代碼,但我不知道我怎麼能寫出選擇部分。
Dim books = System.Xml.Linq.XDocument.Load(_filename).Root.Elements("Book").
Select(/****what should i write here ***/)
Return books
您需要使用'DirectCast'將元素轉換爲字符串。 – XN16