Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PropertyBuilder::SetConstant Method (Object^)

 

Sets the default value of this property.

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

public:
void SetConstant(
	Object^ defaultValue
)

Parameters

defaultValue
Type: System::Object^

The default value of this property.

Exception Condition
InvalidOperationException

CreateType has been called on the enclosing type.

ArgumentException

The property is not one of the supported types.

-or-

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

-or-

The property 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 property 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 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.

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Return to top
Show:
© 2017 Microsoft