PropertyBuilder.SetConstant(Object) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the default value of this property.
public:
void SetConstant(System::Object ^ defaultValue);
public void SetConstant (object? defaultValue);
public void SetConstant (object defaultValue);
member this.SetConstant : obj -> unit
Public Sub SetConstant (defaultValue As Object)
- defaultValue
- Object
The default value of this property.
CreateType() has been called on the enclosing type.
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.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided), 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: