System.Reflection.Emit.PropertyBuilder.SetConstant Method

Sets the default value of this property.

Syntax

public void SetConstant (object defaultValue)

Parameters

defaultValue
The default value of this property.

Remarks

defaultValue is restricted to the following types: Boolean, SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, UInt64, Single, Double, DateTime, Char, String, and Enum. If the property type is a reference type, CLS compliance requires defaultValue to be null. However, starting with the net_v40_long, defaultValue can be non-null for reference types as long as the value can be assigned to that reference type. For example, an Int32 value can be assigned to a property of type object. This is not CLS-compliant, but it can be useful in interop scenarios.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0