ParameterInfo.DefaultValue 屬性


如果參數有預設值,取得表示預設值的值。Gets a value indicating the default value if the parameter has a default value.

 virtual property System::Object ^ DefaultValue { System::Object ^ get(); };
public virtual object DefaultValue { get; }
public virtual object? DefaultValue { get; }
member this.DefaultValue : obj
Public Overridable ReadOnly Property DefaultValue As Object



參數的預設值,或者,如果參數沒有預設值,則為 ValueThe default value of the parameter, or Value if the parameter has no default value.


這個屬性只會在執行內容中使用。This property is used only in the execution context. 在僅限反映的內容中,請改用 RawDefaultValue 屬性。In the reflection-only context, use the RawDefaultValue property instead.

當方法呼叫中未指定實際值時,就會使用預設值。The default value is used when an actual value is not specified in the method call. 參數可以有預設值 nullA parameter can have a default value that is null. 這與未定義預設值的情況不同。This is distinct from the case where a default value is not defined.

這個方法會利用 DefaultValueImpl 方法。This method utilizes the DefaultValueImpl method.

若要取得 ParameterInfo 陣列,請先取得方法或函式,然後再呼叫 MethodBase.GetParametersTo get the ParameterInfo array, first get the method or the constructor and then call MethodBase.GetParameters.