DefaultParameterValueAttribute.DefaultParameterValueAttribute Constructor

Initializes a new instance of the DefaultParameterValueAttribute class with the default value of a parameter.

Namespace: System.Runtime.InteropServices
Assembly: System (in system.dll)

public DefaultParameterValueAttribute (
	Object value
)
public DefaultParameterValueAttribute (
	Object value
)
public function DefaultParameterValueAttribute (
	value : Object
)
Not applicable.

Parameters

value

An object that represents the default value of a parameter.

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.

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);
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: