ParameterBuilder.SetConstant Method

Sets the default value of the parameter.

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

public virtual void SetConstant(
	Object defaultValue
)

Parameters

defaultValue
Type: System.Object

The default value of this parameter.

ExceptionCondition
ArgumentException

The parameter is not one of the supported types.

-or-

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

-or-

The parameter is of type Object or other reference type, defaultValue is not null, 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 null. However, starting with the .NET Framework 4, 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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft