Skip to content

Instantly share code, notes, and snippets.

@AndrewBarfield
Created April 30, 2012 09:39
Show Gist options
  • Save AndrewBarfield/2556878 to your computer and use it in GitHub Desktop.
Save AndrewBarfield/2556878 to your computer and use it in GitHub Desktop.
C#: LINQ: How to construct an XML element
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace LINQExample {
class Program {
static void Main() {
var e = new XElement( "Person",
new XAttribute( "CanCode", true ),
new XElement( "Name", "Loren David" ),
new XElement( "Age", 31 ) );
var s = e.ToString();
Console.WriteLine( s );
// Allow user to read the Console
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment