internal static void Namespace() { XNamespace namespace1 = "http://www.w3.org/XML/1998/namespace"; // Implicitly convert string to XNamespace. XNamespace namespace2 = XNamespace.Xml; XNamespace namespace3 = XNamespace.Get("http://www.w3.org/2000/xmlns/"); (namespace1 == namespace2).WriteLine(); // True (namespace1 != namespace3).WriteLine(); // True XNamespace @namespace = "https://weblogs.asp.net/dixin"; XName name = @namespace + "localName"; // + operator. name.WriteLine(); // {https://weblogs.asp.net/dixin}localName XElement element = new XElement(name, new XAttribute(XNamespace.Xmlns + "dixin", @namespace)); // + operator. element.WriteLine(); // <dixin:localName xmlns:dixin="https://weblogs.asp.net/dixin" /> }