locked
From C# to Vb.net for Xml RRS feed

  • Question

  • User-1264122292 posted

    I am trying to convert

    var books = XElement.Load(info.Stream);
    var bookList = from book in books.Elements("Book")
    orderby (string)book.Attribute("Author")
    select new {
    Name = (string)book.Attribute("Name"),
    Author = (string)book.Attribute("Author")
    };
    foreach(var book in bookList)
    _text.Text += book.ToString() + Environment.NewLine;

    to VB.NET

    However

    For Each book as var In booklist

    is giving the conversion error.

    Any help?

    Thanks in advance.

    Thursday, October 10, 2013 5:55 AM

Answers

  • User-1264122292 posted

    The Answer is

    For Each book In booklist

    :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 10, 2013 6:36 AM

All replies

  • User-1264122292 posted

    The Answer is

    For Each book In booklist

    :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 10, 2013 6:36 AM
  • User397347636 posted

    You also need to have "Option Infer On" in VB to use implicit typing.

    Thursday, October 10, 2013 10:30 AM