有没有人知道下面的代码转换成VB?

时间:2010-12-15 18:17:59

标签: c# vb.net c#-to-vb.net

customers =
                (
                    from c in xDoc.Descendants("customer")
                    orderby c.Attribute("CustomerID").Value

                    select new Customer
                    {
                        ID = c.Attribute("CustomerID").Value,
                        CompanyName = c.Attribute("CompanyName").Value,
                        ContactName = c.Attribute("ContactName").Value,
                        ContactTitle = c.Attribute("ContactTitle").Value,
                        Address = c.Attribute("Address").Value,
                        City = c.Attribute("City").Value,
                        State = c.Attribute("State").Value,
                        ZIPCode = c.Attribute("ZIPCode").Value,
                        Phone = c.Attribute("Phone").Value
                    }
                ).ToList();

1 个答案:

答案 0 :(得分:2)

Dim customers = (From c In xDoc.Descendants("customer")Order By c.Attribute("CustomerID").Value
 Select New Customer() With { _
  .ID = c.Attribute("CustomerID").Value, _
  .CompanyName = c.Attribute("CompanyName").Value, _
  .ContactName = c.Attribute("ContactName").Value, _
  .ContactTitle = c.Attribute("ContactTitle").Value, _
  .Address = c.Attribute("Address").Value, _
  .City = c.Attribute("City").Value, _
  .State = c.Attribute("State").Value, _
  .ZIPCode = c.Attribute("ZIPCode").Value, _
  .Phone = c.Attribute("Phone").Value _
}).ToList()