System.Reflection.ParameterAttributes Enumeration

Assembly: Mscorlib.dll
Namespace: System.Reflection
Summary
Defines the attributes that may be associated with a parameter. These are defined in CorHdr.h.
C# Syntax:
[Flags]
[Serializable]
public enum ParameterAttributes
Remarks
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.

Example
 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;
    }
 }
 /*
 Produces the following output
 
 Reflection.ParameterAttributes
 
 Mymethodbase = Void mymethod (System.String, System.String,
 System.String ByRef)
 
 For the second parameter:
 Myparamattributes = 2, which is an Out
 */

    
See also:
System.Reflection Namespace

System.Reflection.ParameterAttributes Member List:

Public Fields
HasDefault Specifies that the parameter has a default value.
HasFieldMarshal Specifies that the parameter has field marshaling information.
In Specifies that the parameter is an input parameter.
Lcid Specifies that the parameter is a locale identifier (lcid).
None Specifies that there is no parameter attribute.
Optional Specifies that the parameter is optional.
Out Specifies that the parameter is an output parameter.
Reserved3 Reserved.
Reserved4 Reserved.
ReservedMask Specifies that the parameter is reserved.
Retval Specifies that the parameter is a return value.

Hierarchy:


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.