Locked How to convert the following code from C# to VB?

  • Tuesday, August 21, 2007 7:38 AM
     
     

     

    How to convert the following code from C# to VB?
            var photos = (from photo in xroot.Element("photos").Elements("photo")
                        select new PhotoInfo
                        { 
                            Id = (string)photo.Attribute("id"),
                            Owner = (string)photo.Attribute("owner"),
                            Title = (string)photo.Attribute("title"),
                            Secret = (string)photo.Attribute("secret"),
                            Server = (string)photo.Attribute("server"),
                            Farm = (string)photo.Attribute("Farm"),
                        }).Skip(pageIndex*Columns*Rows).Take(Columns*Rows);
    
    Thanks!
    
    

All Replies

  • Thursday, August 23, 2007 2:46 AM
     
     
    Nobody know?

    Please help......thanks!
  • Thursday, August 23, 2007 7:56 PM
     
     

    Try this,

    Dim photos = (From photo In xroot.<photos>.<photo> _

    Select New PhotoInfo( _

    Id = photo.@id, _

    Owner = photo.@owner, _

    Title = photo.@title, _

    Secret = photo.@secret, _

    Server = photo.@server, _

    Farm = photo.@Farm, _

    )).Skip(pageIndex * columns * rows).Take(columns * rows)

     

  • Friday, August 24, 2007 2:23 AM
     
     

    I try the code you provided, and an error message is prompted as following:

     

    'Select' is not a member of 'System.Collections.Generic.IEnumerable(Of System.Xml.XLinq.XElement)'. 

     

    I wonder why this happen?  Thanks.

  • Friday, August 24, 2007 3:24 PM
     
     
    First step, move up from the 2006 May CTP and grab Beta2. XLinq has been changed to System.Xml.Linq quite a while ago. I responded to your items over in the LINQ forum. The answers will need Beta 2 to work, particularly on the on that uses the VB Lambda implementation as that didn't appear until beta 1.

     

    Jim

    http://www.devauthority.com/blogs/jwooley

    http://www.LinqInAction.net

  • Tuesday, August 28, 2007 5:15 AM
     
     
    Where can I find the 2006 May CTP Beta2?  Because I tried to install "Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP", but fail.

    For your reference, I have the following installed in my PC:

    - Microsoft .NET Framework 2.0 Service Pack 1
    - Microsoft .NET Framework 3.0 Service Pack 1
    - Microsoft .NET Framework 3.5 (Pre-Release Version)

    Thanks!
  • Tuesday, August 28, 2007 4:46 PM
     
     

     

    Why do you want the 2006 CTP? You should get the (7/2007) Beta 2 drop at http://msdn2.microsoft.com/en-us/vstudio/default.aspx.

     

    Jim Wooley

    http://www.devauthority.com/blogs/jwooley

    http://www.LinqInAction.net