AllowNullAttribute Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Allows a NULL as the argument to a mandatory parameter.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

System::Object
  System::Attribute
    System.Management.Automation.Internal::CmdletMetadataAttribute
      System.Management.Automation::AllowNullAttribute

[AttributeUsageAttribute(AttributeTargets::Property | AttributeTargets::Field)]
public ref class AllowNullAttribute sealed : CmdletMetadataAttribute

NameDescription
System_CAPS_pubmethodAllowNullAttribute()

Initializes a new instance of the AllowNullAttribute class.

NameDescription
System_CAPS_pubpropertyTypeId

(Inherited from Attribute.)

NameDescription
System_CAPS_pubmethodEquals(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

When this attribute is used null is converted to the parameter type. This means that adding AllowNull to the following parameter types is not useful.

  • String parameters should not use this attribute because null is converted to the empty string.

  • Value type parameters should not use this attribute because null is converted to 0 for numeric types, and null cannot be converted to most other value types.

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: