ParameterBuilder.SetConstant Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Sets the default value of the parameter.

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)


Public Overridable Sub SetConstant ( _
    defaultValue As Object _
public virtual void SetConstant(
    Object defaultValue



Exception Condition

The parameter is not one of the supported types.


The type of defaultValue does not match the type of the parameter.


The parameter is of type Object or other reference type, defaultValue is not nullNothingnullptra null reference (Nothing in Visual Basic), and the value cannot be assigned to the reference type.


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 parameter type is a reference type, CLS compliance requires defaultValue to be nullNothingnullptra null reference (Nothing in Visual Basic). However, starting with Windows Phone OS 7.1, defaultValue can be non-null for a reference type as long as the value can be assigned to that reference type. For example, an Int32 value can be assigned to a parameter of type Object. This is not CLS-compliant, but it can be useful in interop scenarios.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1


Windows Phone

See Also


ParameterBuilder Class

System.Reflection.Emit Namespace