You cannot control the type of the data that is returned by the LINQ query. The type is determined by the LINQ provider (in this case, the LINQ to XML provider). What you do know, however, is that whatever it returns, it will always implement IEnumerable
. Since the String.Join
method has an overload which takes an IEnumerable
parameter, you don't need to first convert it to an array:
Dim elem As XElement = <Table1>
<Field1>1</Field1>
<Field2>example1</Field2>
<Field1></Field1>
<Field4>540</Field4>
</Table1>
Dim string1 As String = String.Join(",", From p In elem.Elements Select p.Name)
Dim string2 As String = String.Join(",", From p In elem.Elements Select p.Value)