I write a lot of code using System.Xml.Linq in VB.net and c#, but there is a few things I can do in VB that I haven't worked out how to do in c#. Could anyone tell me how to do the following examples
Public Sub Test()
'Exmaple 1 - get an attribute value with the .@ Access Method instead of
'testVal.Attribute("Test").Value
Dim test As New XElement("Test", New XAttribute("Test", "My Value"))
Dim testVal = test.@Test
'testVal equals "My Value"
'Exmaple 2 - create an element by just typing xml
Dim test2 As XElement = <Test Test="My Value"></Test>
'Exmaple 3 - not much of a priority - but using the following syntax to get elements
'rather than test.Decendents("Cars").Elements("Car")
Dim x = test...<Cars>.<Car>
'Returns my IEnumerable<XElement>
End Sub
I know how to do the above examples using various methods etc. But was wondering if there is a way of writing code in the way I have in VB in C#. The sort of shorthand way I suppose. Can I reference visual basic assemblies to achieve this for example?
Thanks in advance! :)