Instructs the Serialize method of the XmlSerializer not to serialize the public field or public read/write property value.
For a list of all members of this type, see XmlIgnoreAttribute Members.
System.Object
System.Attribute
System.Xml.Serialization.XmlIgnoreAttribute
[Visual Basic] <AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field _ Or AttributeTargets.Parameter Or AttributeTargets.ReturnValue)> Public Class XmlIgnoreAttribute Inherits Attribute [C#] [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue)] public class XmlIgnoreAttribute : Attribute [C++] [AttributeUsage(AttributeTargets::Property | AttributeTargets::Field | AttributeTargets::Parameter | AttributeTargets::ReturnValue)] public __gc class XmlIgnoreAttribute : public Attribute [JScript] public AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue) class XmlIgnoreAttribute extends Attribute
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
The XmlIgnoreAttribute belongs to a family of attributes that controls how the XmlSerializer. serializes, or deserializes, an object. If you apply the XmlIgnoreAttribute to any member of a class, the XmlSerializer ignores the member when serializing or deserializing an instance of the class. For a complete list of similar attributes, see
You can override the behavior caused by the XmlIgnoreAttribute by creating an XmlAttributes object, and setting its XmlIgnore property to false. You must Add the XmlAttributes object to an instance of the XmlAttributeOverrides class. Lastly, you must use the XmlAttributeOverrides object to construct an instance of the XmlSerializer class before you call the Serialize or Deserialize methods.
The
For more information about using attributes, see
Note In your code, you can use the word XmlIgnore instead of the longer XmlIgnoreAttribute.
[Visual Basic, C#] The following example shows a class named Group, which contains a field named Comment. The example assigns the XmlIgnoreAttribute to the field, thereby instructing the XmlSerializer to ignore the field when serializing or deserializing an instance of the class.
[Visual Basic] Public Class Group ' the XmlSerializer ignores this field. <XmlIgnore()> Public Comment As String ' The XmlSerializer serializes this field. Public GroupName As String End Class [C#] public class Group { // The XmlSerializer ignores this field. [XmlIgnore] public string Comment; // The XmlSerializer serializes this field. public string GroupName; }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System.Xml.Serialization
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: System.Xml (in System.Xml.dll)
XmlIgnoreAttribute Members | System.Xml.Serialization Namespace | XmlAttributeOverrides | XmlAttributes | XmlIgnore | XmlSerializer |