NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ParameterInfo.Name

Retrieves the name of the parameter.

[Visual Basic]
Overridable Public ReadOnly Property Name As String
[C#]
public string Name {virtual get;}
[C++]
public: __property virtual String* get_Name();
[JScript]
public function get Name() : String;

Property Value

Read-only. Retrieves a String containing the simple name of this parameter.

Remarks

The string value for the parameter name is obtained by this method.

This method utilizes the protected NameImpl method.

This method depends on an optional metadata and may not be available in all compilers.

To get the ParameterInfo array, first get the method. From the method, get the Type. From the Type, get the ParameterInfo array.

Example [C#]

[C#]

class
parminfo
{
   public static void mymethod (
      [in] int int1m, out string str2m, ref string str3m)
   {
      str2m = "in mymethod";
   }
 
   public static int Main(string[] args)
   {   
      Console.WriteLine("\nReflection.Parameterinfo");
      
      //Get the ParameterInfo parameter of a function.
 
      //Get the type
      Type Mytype = Type.GetType("parminfo");
 
      //Get and display the method
      MethodBase Mymethodbase = Mytype.GetMethod("mymethod");
      Console.Write("\nMymethodbase = " + Mymethodbase);
 
      //Get the ParameterInfo array
      ParameterInfo[] Myarray = Mymethodbase.GetParameters();
      
      //Get and display the name of each parameter
      foreach (ParameterInfo Myparam in Myarray)
      {
         Console.Write ("\nFor parameter # "   + Myparam.Position 
+ ", the Name is - " +  Myparam.Name);
      }
      return 0;
   }
}
Produces
the following output
Reflection.Parameterinfo
 
Mymethodbase
= Void mymethod (Int32, System.String ByRef, System.String ByRef)
For parameter # 0, the Name is - int1m
For parameter # 1, the Name is - str2m
For parameter # 2, the Name is - str3m

See Also

ParameterInfo Class | ParameterInfo Members | System.Reflection Namespace