DefaultParameterValueAttribute(Object) DefaultParameterValueAttribute(Object) DefaultParameterValueAttribute(Object) DefaultParameterValueAttribute(Object) Constructor

定义

用参数的默认值初始化 DefaultParameterValueAttribute 类的新实例。Initializes a new instance of the DefaultParameterValueAttribute class with the default value of a parameter.

public:
 DefaultParameterValueAttribute(System::Object ^ value);
public DefaultParameterValueAttribute (object value);
new System.Runtime.InteropServices.DefaultParameterValueAttribute : obj -> System.Runtime.InteropServices.DefaultParameterValueAttribute
Public Sub New (value As Object)

参数

value
Object Object Object Object

表示参数默认值的对象。An object that represents the default value of a parameter.

示例

下面的代码示例演示如何将DefaultParameterValueAttribute特性应用于在中C#编写的方法的参数。The following code example demonstrates how to apply the DefaultParameterValueAttribute attribute to a parameter of a method written in C#.

static public void MethodWithDefaultParam([System.Runtime.InteropServices.DefaultParameterValue("DEFAULT_PARAM_VALUE")] string var)
{
	Console.WriteLine("The passed value is: " + var);
}

注解

使用此构造函数可将DefaultParameterValueAttribute特性应用于使用不支持默认参数的语言 (如C# Microsoft Visual) 编写的参数。Use this constructor to apply the DefaultParameterValueAttribute attribute to a parameter written in a language such as Microsoft Visual C# that does not support default parameters.

适用于