XmlArrayAttribute.IsNullable Proprietà

Definizione

Ottiene o imposta un valore che indica se XmlSerializer deve serializzare un membro come un tag XML vuoto con l'attributo xsi:nil impostato su 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

Valore della proprietà

true se l'attributo xsi:nil viene generato dalla classe XmlSerializer; in caso contrario, false.

Esempio

L'esempio seguente contiene due matrici: una con la IsNullable proprietà impostata su truee un'altra con la IsNullable proprietà impostata su 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

Commenti

La specifica XML Schema per le strutture consente a un documento XML di segnalare in modo esplicito che il contenuto di un elemento non è presente. Tale elemento contiene l'attributo xsi:nil impostato su true. Per altre informazioni, vedere la specifica del World Wide Web Consortium intitolata XML Schema Part 1: Structures.

Se la IsNullable proprietà è impostata su true, l'attributo xsi:nil viene generato per i membri della classe che sono stati impostati su null. Ad esempio, se si imposta un campo denominato MyStringArray su null, viene XmlSerializer generato il codice XML seguente.

<MyStringArray xsi:nil = "true" />  

Se la IsNullable proprietà è false, non viene generato alcun elemento XML.

Nota

Non è possibile applicare la IsNullable proprietà a un membro tipizzato come tipo valore perché un tipo valore non può contenere null.

Si applica a