Mega Code Archive

 
Categories / C# Book / 05 LINQ XML
 

0542 XName

XName overloads the + operator, allowing you to combine a namespace and name without using braces. using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Text; using System.IO; class Program { static void Main() { XNamespace ns = "http://domain.com/xmlspace"; XName fullName = ns + "customer"; Console.WriteLine(fullName); //{http://domain.com/xmlspace}customer } } The output: