ParameterAttributes Enumeration

Defines the attributes that can be associated with a parameter. These are defined in CorHdr.h.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public enum ParameterAttributes
/** @attribute SerializableAttribute() */ 
/** @attribute FlagsAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum ParameterAttributes
public enum ParameterAttributes

 Member nameDescription
Supported by the .NET Compact FrameworkHasDefaultSpecifies that the parameter has a default value. 
Supported by the .NET Compact FrameworkHasFieldMarshalSpecifies that the parameter has field marshaling information. 
Supported by the .NET Compact FrameworkInSpecifies that the parameter is an input parameter. 
Supported by the .NET Compact FrameworkLcidSpecifies that the parameter is a locale identifier (lcid). 
Supported by the .NET Compact FrameworkNoneSpecifies that there is no parameter attribute. 
Supported by the .NET Compact FrameworkOptionalSpecifies that the parameter is optional. 
Supported by the .NET Compact FrameworkOutSpecifies that the parameter is an output parameter. 
Supported by the .NET Compact FrameworkReserved3Reserved. 
Supported by the .NET Compact FrameworkReserved4Reserved. 
Supported by the .NET Compact FrameworkReservedMaskSpecifies that the parameter is reserved. 
Supported by the .NET Compact FrameworkRetvalSpecifies that the parameter is a return value. 

To get the ParameterAttributes value, first get the Type. From the Type, get the ParameterInfo array. The ParameterAttributes value is within the array.

These enumerator values are dependent on optional metadata. Not all attributes are available from all compilers. See the appropriate compiler instructions to determine which enumerated values are available.

The following example displays the attributes of the specified parameter.

using System;
using System.Reflection;
class paramatt
    public static void mymethod (string str1, out string str2, ref string str3)
        str2 = "string";
    public static int Main(string[] args)
        // Get the Type and the method.
        Type Mytype = Type.GetType("paramatt");
        MethodBase Mymethodbase = Mytype.GetMethod("mymethod");
        // Display the method.
        Console.Write("\nMymethodbase = " + Mymethodbase);
        // Get the ParameterInfo array.
        ParameterInfo[] Myarray = Mymethodbase.GetParameters();
        // Get and display the attributes for the second parameter.
        ParameterAttributes Myparamattributes = Myarray[1].Attributes;
        Console.Write("\nFor the second parameter:\nMyparamattributes = " 
            + (int) Myparamattributes
            + ", which is an "
            + Myparamattributes.ToString());
        return 0;

import System.*;
import System.Reflection.*;

class Paramatt
    public static void Mymethod(String str1,
		/**	@ref
		 */ String str2,
        /**	@ref
         */ String str3)
        str2 = "string";
    } //Mymethod

    public static void main(String[] args)

        // Get the Type and the method.
        Type myType = Type.GetType("Paramatt");
        MethodBase myMethodBase = myType.GetMethod("Mymethod");

        // Display the method.
        Console.Write(("\nMymethodbase = " + myMethodBase));

        // Get the ParameterInfo array.
        ParameterInfo myArray[] = myMethodBase.GetParameters();

        // Get and display the attributes for the second parameter.
        ParameterAttributes myParamAttributes = myArray[1].get_Attributes();

        Console.Write(("\nFor the second parameter:\nMyparamattributes = " 
            + (int)(myParamAttributes) + ", which is an " 
            + myParamAttributes.ToString()));
    } //main
} //Paramatt

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, 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, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0