PropertyBuilder.SetConstant(Object) Método
Definição
Define o valor padrão dessa propriedade.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)
Parâmetros
- defaultValue
- Object
O valor padrão dessa propriedade.The default value of this property.
Exceções
O CreateType() foi chamado no tipo de delimitador.CreateType() has been called on the enclosing type.
A propriedade não é de um dos tipos com suporte.The property is not one of the supported types.
- ou --or-
O tipo de defaultValue não corresponde ao tipo da propriedade.The type of defaultValue does not match the type of the property.
- ou --or-
A propriedade é do tipo Object ou outro tipo de referência, defaultValue não é null e o valor não pode ser atribuído ao tipo de referência.The property is of type Object or other reference type, defaultValue is not null, and the value cannot be assigned to the reference type.
Comentários
defaultValue é restrito aos seguintes tipos:,,,,, Boolean SByte Int16 Int32 Int64 Byte , UInt16 , UInt32 ,,,,, UInt64 Single Double DateTime Char , String e Enum .defaultValue is restricted to the following types: Boolean, SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, UInt64, Single, Double, DateTime, Char, String, and Enum. Se o tipo de propriedade for um tipo de referência, a conformidade com CLS exigirá defaultValue que seja null .If the property type is a reference type, CLS compliance requires defaultValue to be null. No entanto, começando com o .NET Framework 4, defaultValue pode ser não nulo para tipos de referência, desde que o valor possa ser atribuído a esse tipo de referência.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. Por exemplo, um Int32 valor pode ser atribuído a uma propriedade do tipo Object .For example, an Int32 value can be assigned to a property of type Object. Isso não é compatível com CLS, mas pode ser útil em cenários de interoperabilidade.This is not CLS-compliant, but it can be useful in interop scenarios.