Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

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
Assemblies:   System.Reflection.Primitives (in System.Reflection.Primitives.dll)
  mscorlib (in mscorlib.dll)

[FlagsAttribute]
public enum ParameterAttributes

Member nameDescription
Supported by the XNA FrameworkSupported by Portable Class LibraryHasDefaultSpecifies that the parameter has a default value.
Supported by the XNA FrameworkSupported by Portable Class LibraryHasFieldMarshalSpecifies that the parameter has field marshaling information.
Supported by the XNA FrameworkSupported by Portable Class LibraryInSpecifies that the parameter is an input parameter.
Supported by the XNA FrameworkSupported by Portable Class LibraryLcidSpecifies that the parameter is a locale identifier (lcid).
Supported by the XNA FrameworkSupported by Portable Class LibraryNoneSpecifies that there is no parameter attribute.
Supported by the XNA FrameworkSupported by Portable Class LibraryOptionalSpecifies that the parameter is optional.
Supported by the XNA FrameworkSupported by Portable Class LibraryOutSpecifies that the parameter is an output parameter.
Supported by the XNA FrameworkReserved3Reserved.
Supported by the XNA FrameworkReserved4Reserved.
Supported by the XNA FrameworkReservedMaskSpecifies that the parameter is reserved.
Supported by the XNA FrameworkSupported by Portable Class LibraryRetvalSpecifies 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)
    {
        Console.WriteLine("\nReflection.ParameterAttributes");

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft