System.Runtime.InteropServices.DefaultParameterValueAttribute Class

Sets the default value of a parameter when called from a language that supports default parameters. This class cannot be inherited.

See Also: DefaultParameterValueAttribute Members

Syntax

[System.AttributeUsage(System.AttributeTargets.Parameter)]
public sealed class DefaultParameterValueAttribute : Attribute

Remarks

The System.Runtime.InteropServices.DefaultParameterValueAttribute attribute allows you to specify a default parameter value in a language that does not otherwise support default parameters. After you apply this attribute to your code, languages that support default parameters can use the specified value as a default parameter.

Note that the System.Runtime.InteropServices.DefaultParameterValueAttribute does not add support for default parameters to languages that do not support this feature. For example, if you use the System.Runtime.InteropServices.DefaultParameterValueAttribute with a method written in C#, which does not support default parameters, you cannot use the default parameter when calling the method from C#. You can use the default parameter only when calling the method in a language such as C++ that does support the feature.

The System.Runtime.InteropServices.DefaultParameterValueAttribute is particularly useful to specify default parameters for methods of a COM interop interface.

Requirements

Namespace: System.Runtime.InteropServices
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0