2012-05-16 99 views
0

我是新的VB.net並希望得到一些幫助。 我如何轉換下面的代碼從C#到VB.NET如何將下面的代碼從C#轉換爲VB.net(linq轉換爲xml)

protected override Func<XElement, Person> Selector  
    {   
     get   
     {    
      return x => new Person() 
      {     
       Id = x.Attribute("Id").GetGuid(),     
        FirstName = x.Attribute("FirstName").Value,     
        LastName = x.Attribute("LastName").Value,     
         Dias = x.Attribute("Dias").GetByte()    

      };   
     }  
    } 

回答

0

我發現這個免費工具的工作轉換C#來Vb.net相當不錯:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

結果:

Protected Overrides ReadOnly Property Selector() As Func(Of XElement, Person) 
    Get 

     Return Function(x) New Person() With { _ 
      Key .Id = x.Attribute("Id").GetGuid(), _ 
      Key .FirstName = x.Attribute("FirstName").Value, _ 
      Key .LastName = x.Attribute("LastName").Value, _ 
      Key .Dias = x.Attribute("Dias").GetByte() _ 
     } 
    End Get 
End Property