Why you cannot create instance of XName

If you are familiar with XDocument, you will know that this is now lega.

 

var xname = new XName("Condition");
 

however, you may need to use XName in some occasions, so how can the XName instance spring into existence?

 

The magics is the implicit conversion operator.

 

public sealed class XName : IEquatable<XName>, ISerializable
{

    [CLSCompliant(false)]
    public static implicit operator XName(string expandedName);
   ...
}
 

 

so you can directly do something like this:

 

XName xname = "Condition"
 

 

 

你可能感兴趣的:(Why you cannot create instance of XName)