次の方法で共有


LogicalMethodInfo.Parameters プロパティ

このメソッドのパラメータを取得します。

Public ReadOnly Property Parameters As ParameterInfo ()
[C#]
public ParameterInfo[] Parameters {get;}
[C++]
public: __property ParameterInfo* get_Parameters();
[JScript]
public function get Parameters() : ParameterInfo[];

プロパティ値

メソッドのパラメータを表す ParameterInfo の配列。

解説

パラメータのデータ型、既定値などに関する情報を取得するには、 ParameterInfo を使用します。

Parameters は、メソッドに渡されたパラメータを順に表す ParameterInfo オブジェクトの配列を返します。

使用例

 
Imports System
Imports System.Reflection
Imports System.Web.Services.Protocols
Imports Microsoft.VisualBasic

Public Class MyService
   
   Public Function Add(xValue As Integer, yValue As Integer) As Integer
      Return xValue + yValue
   End Function 'Add
End Class 'MyService

Public Class LogicalMethodInfo_Constructor
   
   Public Shared Sub Main()
      Dim myType As Type = GetType(MyService)
      Dim myMethodInfo As MethodInfo = myType.GetMethod("Add")
      Dim myLogicalMethodInfo As New LogicalMethodInfo(myMethodInfo)
      
      Console.WriteLine(ControlChars.NewLine + "Printing properties of method : {0}" + _
                              ControlChars.NewLine, myLogicalMethodInfo.ToString())
      
      Console.WriteLine(ControlChars.NewLine + "The declaring type of the method {0} is :" + _
                                    ControlChars.NewLine, myLogicalMethodInfo.Name)
      Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.DeclaringType.ToString())
      
      Console.WriteLine(ControlChars.NewLine + "The parameters of the method {0} are :" + _
                                    ControlChars.NewLine, myLogicalMethodInfo.Name)
      Dim myParameters As ParameterInfo() = myLogicalMethodInfo.Parameters
      Dim i As Integer
      For i = 0 To myParameters.Length - 1
         Console.WriteLine(ControlChars.Tab + myParameters(i).Name + " : " + _
                                                      myParameters(i).ParameterType.ToString())
      Next i
      
      Console.WriteLine(ControlChars.NewLine + "The return type of the method {0} is :" + _
                                             ControlChars.NewLine, myLogicalMethodInfo.Name)
      Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.ReturnType.ToString())
      
      Dim service As New MyService()
      Console.WriteLine(ControlChars.NewLine + "Invoking the method {0}" + _
                                                ControlChars.NewLine, myLogicalMethodInfo.Name)
      Console.WriteLine(ControlChars.Tab + "The sum of 10 and 10 is : {0}", _
                                    myLogicalMethodInfo.Invoke(service, New Object() {10, 10}))
   End Sub 'Main
End Class 'LogicalMethodInfo_Constructor

[C#] 
using System;
using System.Reflection;
using System.Web.Services.Protocols;

public class MyService 
{
   public int Add(int xValue, int yValue)
   {
      return (xValue + yValue);
   }
}

public class LogicalMethodInfo_Constructor
{
   public static void Main()
   {
      Type myType = typeof(MyService);
      MethodInfo myMethodInfo = myType.GetMethod("Add");
      LogicalMethodInfo myLogicalMethodInfo = 
                  new LogicalMethodInfo(myMethodInfo);

      Console.WriteLine("\nPrinting properties of method : {0}\n",
                              myLogicalMethodInfo.ToString());

      Console.WriteLine("\nThe declaring type of the method {0} is :\n",
                              myLogicalMethodInfo.Name);
      Console.WriteLine("\t" + myLogicalMethodInfo.DeclaringType);

      Console.WriteLine("\nThe parameters of the method {0} are :\n",
                              myLogicalMethodInfo.Name);
      ParameterInfo[] myParameters = myLogicalMethodInfo.Parameters;
      for(int i = 0; i < myParameters.Length; i++)
      {
         Console.WriteLine("\t" + myParameters[i].Name +
                                 " : " + myParameters[i].ParameterType);
      }

      Console.WriteLine("\nThe return type of the method {0} is :\n",
                              myLogicalMethodInfo.Name);
      Console.WriteLine("\t" + myLogicalMethodInfo.ReturnType);

      MyService service = new MyService();
      Console.WriteLine("\nInvoking the method {0}\n",
                              myLogicalMethodInfo.Name);
      Console.WriteLine("\tThe sum of 10 and 10 is : {0}",
                              myLogicalMethodInfo.Invoke(service, 
                                                   new object[] {10, 10}));
   }  
}

[C++] 
#using <mscorlib.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

public __gc class MyService {
public:
   int Add(int xValue, int yValue) {
      return (xValue + yValue);
   }
};

int main() {
   Type*  myType = __typeof(MyService);
   MethodInfo*  myMethodInfo = myType->GetMethod(S"Add");
   LogicalMethodInfo* myLogicalMethodInfo =
      new LogicalMethodInfo(myMethodInfo);

   Console::WriteLine(S"\nPrinting properties of method : {0}\n",
      myLogicalMethodInfo);

   Console::WriteLine(S"\nThe declaring type of the method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->DeclaringType);

   Console::WriteLine(S"\nThe parameters of the method {0} are :\n",
      myLogicalMethodInfo->Name);
   ParameterInfo*  myParameters[] = myLogicalMethodInfo->Parameters;

   for (int i = 0; i < myParameters->Length; i++) {
      Console::WriteLine(S"\t {0}",String::Concat(myParameters[i]->Name,
         S" : ", myParameters[i]->ParameterType));
   }

   Console::WriteLine(S"\nThe return type of the method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->ReturnType);

   MyService* service = new MyService();
   Console::WriteLine(S"\nInvoking the method {0}\n",
      myLogicalMethodInfo->Name);
   Object * values __gc[] = new Object * [2];
   values[0] = __box(10);
   values[1] = __box(10);

   Console::WriteLine(S"\tThe sum of 10 and 10 is : {0}",
      myLogicalMethodInfo->Invoke(service,values));

}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

LogicalMethodInfo クラス | LogicalMethodInfo メンバ | System.Web.Services.Protocols 名前空間 | InParameters | OutParameters