如何将以下代码从C#转换为VB.net(linq到xml)

时间:2012-05-16 19:20:38

标签: linq-to-xml

我是新的VB.net,希望得到一些帮助。 如何将以下代码从C#转换为VB.NET

    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()               

            };         
        }     
    } 

1 个答案:

答案 0 :(得分: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