XmlArrayAttribute.IsNullable Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that indicates whether the XmlSerializer must serialize a member as an empty XML tag with the xsi:nil
attribute set to true
.
public:
property bool IsNullable { bool get(); void set(bool value); };
public bool IsNullable { get; set; }
member this.IsNullable : bool with get, set
Public Property IsNullable As Boolean
Property Value
true
if the XmlSerializer generates the xsi:nil
attribute; otherwise, false
.
Examples
The following example contains two arrays: one with the IsNullable property set to true
, and another with the IsNullable property set to false
.
public ref class MyClass
{
public:
[XmlArray(IsNullable=true)]
array<String^>^IsNullableIsTrueArray;
[XmlArray(IsNullable=false)]
array<String^>^IsNullableIsFalseArray;
};
public class MyClass
{
[XmlArray (IsNullable = true)]
public string [] IsNullableIsTrueArray;
[XmlArray (IsNullable = false)]
public string [] IsNullableIsFalseArray;
}
Public Class MyClass1
<XmlArray(IsNullable := True)> _
Public IsNullableIsTrueArray() As String
<XmlArray(IsNullable := False)> _
Public IsNullableIsFalseArray() As String
End Class
Remarks
The XML schema specification for structures allows an XML document to explicitly signal that an element's content is missing. Such an element contains the attribute xsi:nil
set to true
. For more information, see the World Wide Web Consortium specification titled XML Schema Part 1: Structures.
If the IsNullable property is set to true
, the xsi:nil
attribute is generated for class members that have been set to null
. For example, if you set a field named MyStringArray
to null
, the XmlSerializer generates the following XML code.
<MyStringArray xsi:nil = "true" />
If the IsNullable property is false
, no XML element is generated.
Note
You cannot apply the IsNullable property to a member typed as a value type because a value type cannot contain null
.
Applies to
.NET