Compartir a través de


Clase DefaultParameterValueAttribute

 

Publicado: octubre de 2016

Establece el valor predeterminado de un parámetro cuando se le llama desde un lenguaje que admite parámetros predeterminados. Esta clase no puede heredarse.

Espacio de nombres:   System.Runtime.InteropServices
Ensamblado:  System (en System.dll)

Jerarquía de herencia

System.Object
  System.Attribute
    System.Runtime.InteropServices.DefaultParameterValueAttribute

Sintaxis

[AttributeUsageAttribute(AttributeTargets.Parameter)]
public sealed class DefaultParameterValueAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Parameter)]
public ref class DefaultParameterValueAttribute sealed : Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Parameter)>]
type DefaultParameterValueAttribute = 
    class
        inherit Attribute
    end
<AttributeUsageAttribute(AttributeTargets.Parameter)>
Public NotInheritable Class DefaultParameterValueAttribute
    Inherits Attribute

Constructores

Nombre Descripción
System_CAPS_pubmethod DefaultParameterValueAttribute(Object)

Inicializa una nueva instancia de la DefaultParameterValueAttribute clase con el valor predeterminado de un parámetro.

Propiedades

Nombre Descripción
System_CAPS_pubproperty TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.(Heredado de Attribute).

System_CAPS_pubproperty Value

Obtiene el valor predeterminado de un parámetro.

Métodos

Nombre Descripción
System_CAPS_pubmethod Equals(Object)

Esta API admite la infraestructura producto y no está diseñada para usarse directamente desde el código. Devuelve un valor que indica si esta instancia es igual que un objeto especificado.(Heredado de Attribute).

System_CAPS_pubmethod GetHashCode()

Devuelve el código hash de esta instancia.(Heredado de Attribute).

System_CAPS_pubmethod GetType()

Obtiene el Type de la instancia actual.(Heredado de Object).

System_CAPS_pubmethod IsDefaultAttribute()

Si se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.(Heredado de Attribute).

System_CAPS_pubmethod Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.(Heredado de Attribute).

System_CAPS_pubmethod ToString()

Devuelve una cadena que representa el objeto actual.(Heredado de Object).

Implementaciones de interfaz explícitas

Nombre Descripción
System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.(Heredado de Attribute).

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.(Heredado de Attribute).

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).(Heredado de Attribute).

System_CAPS_pubinterfaceSystem_CAPS_privmethod _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.(Heredado de Attribute).

Comentarios

The T: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 T: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 T: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 T:System.Runtime.InteropServices.DefaultParameterValueAttribute is particularly useful to specify default parameters for methods of a COM interop interface.

Ejemplos

The following code example demonstrates how to apply the T:System.Runtime.InteropServices.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);
}

Información de versión

Plataforma universal de Windows
Disponible desde 8
.NET Framework
Disponible desde 2.0
Biblioteca de clases portable
Se admite en: plataformas portátiles de .NET
Windows Phone
Disponible desde 8.1

Seguridad para subprocesos

Cualquier miembro ( Compartido en Visual Basic) estático público de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Ver también

Espacio de nombres System.Runtime.InteropServices

Volver al principio