LogicalMethodInfo.OutParameters Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient les paramètres out de la méthode.
public:
property cli::array <System::Reflection::ParameterInfo ^> ^ OutParameters { cli::array <System::Reflection::ParameterInfo ^> ^ get(); };
public System.Reflection.ParameterInfo[] OutParameters { get; }
member this.OutParameters : System.Reflection.ParameterInfo[]
Public ReadOnly Property OutParameters As ParameterInfo()
Valeur de propriété
Tableau ParameterInfo représentant les paramètres out de la méthode, dans l'ordre.
Exemples
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;
public ref class MyService
{
public:
void MyMethod( int inParameter, [Out]interior_ptr<int> outParameter )
{
*outParameter = inParameter;
}
};
int main()
{
Type^ myType = MyService::typeid;
MethodInfo^ myMethodInfo = myType->GetMethod( "MyMethod" );
array<MethodInfo^>^temparray = {myMethodInfo};
LogicalMethodInfo^ myLogicalMethodInfo = (LogicalMethodInfo::Create( temparray ))[ 0 ];
Console::WriteLine( "\nPrinting parameters for the method : {0}", myLogicalMethodInfo->Name );
Console::WriteLine( "\nThe parameters of the method {0} are :\n", myLogicalMethodInfo->Name );
array<ParameterInfo^>^myParameters = myLogicalMethodInfo->Parameters;
for ( int i = 0; i < myParameters->Length; i++ )
{
Console::WriteLine( String::Concat( "\t ", myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) );
}
Console::WriteLine( "\nThe in parameters of the method {0} are :\n", myLogicalMethodInfo->Name );
myParameters = myLogicalMethodInfo->InParameters;
for ( int i = 0; i < myParameters->Length; i++ )
{
Console::WriteLine( String::Concat( "\t ", myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) );
}
Console::WriteLine( "\nThe out parameters of the method {0} are :\n", myLogicalMethodInfo->Name );
myParameters = myLogicalMethodInfo->OutParameters;
for ( int i = 0; i < myParameters->Length; i++ )
{
Console::WriteLine( String::Concat( "\t ", myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) );
}
if ( myLogicalMethodInfo->IsVoid )
Console::WriteLine( "\nThe return type is void" );
else
Console::WriteLine( "\nThe return type is {0}", myLogicalMethodInfo->ReturnType );
}
using System;
using System.Reflection;
using System.Web.Services.Protocols;
public class MyService
{
public void MyMethod(int inParameter, out int outParameter)
{
outParameter = inParameter;
}
}
public class LogicalMethodInfo_Create
{
public static void Main()
{
Type myType = typeof(MyService);
MethodInfo myMethodInfo = myType.GetMethod("MyMethod");
LogicalMethodInfo myLogicalMethodInfo =
(LogicalMethodInfo.Create(new MethodInfo[] {myMethodInfo}))[0];
Console.WriteLine("\nPrinting parameters for the method : {0}",
myLogicalMethodInfo.Name);
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 in parameters of the method {0} are :\n",
myLogicalMethodInfo.Name);
myParameters = myLogicalMethodInfo.InParameters;
for(int i = 0; i < myParameters.Length; i++)
{
Console.WriteLine("\t" + myParameters[i].Name +
" : " + myParameters[i].ParameterType);
}
Console.WriteLine("\nThe out parameters of the method {0} are :\n",
myLogicalMethodInfo.Name);
myParameters = myLogicalMethodInfo.OutParameters;
for(int i = 0; i < myParameters.Length; i++)
{
Console.WriteLine("\t" + myParameters[i].Name +
" : " + myParameters[i].ParameterType);
}
if(myLogicalMethodInfo.IsVoid)
Console.WriteLine("\nThe return type is void");
else
Console.WriteLine("\nThe return type is {0}",
myLogicalMethodInfo.ReturnType);
}
}
Imports System.Reflection
Imports System.Web.Services.Protocols
Public Class MyService
Public Sub MyMethod(inParameter As Integer, ByRef outParameter As Integer)
outParameter = inParameter
End Sub
End Class
Public Class LogicalMethodInfo_Create
Public Shared Sub Main()
Dim myType As Type = GetType(MyService)
Dim myMethodInfo As MethodInfo = myType.GetMethod("MyMethod")
Dim myLogicalMethodInfo As LogicalMethodInfo = _
LogicalMethodInfo.Create(New MethodInfo() {myMethodInfo})(0)
Console.WriteLine _
(ControlChars.Newline + "Printing parameters for the method : {0}", myLogicalMethodInfo.Name)
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 in parameters of the method {0} are :" + _
ControlChars.Newline, myLogicalMethodInfo.Name)
myParameters = myLogicalMethodInfo.InParameters
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 out parameters of the method {0} are :" + _
ControlChars.Newline, myLogicalMethodInfo.Name)
myParameters = myLogicalMethodInfo.OutParameters
For i = 0 To myParameters.Length - 1
Console.WriteLine(ControlChars.Tab + myParameters(i).Name + " : " + _
myParameters(i).ParameterType.toString())
Next i
If myLogicalMethodInfo.IsVoid Then
Console.WriteLine(ControlChars.Newline + "The return type is void")
Else
Console.WriteLine _
(ControlChars.Newline + "The return type is {0}", myLogicalMethodInfo.ReturnType)
End If
End Sub
End Class
Remarques
Utilisez un ParameterInfo pour obtenir des informations sur le type de données du paramètre, sa valeur par défaut, etc.
S’applique à
Voir aussi
Collaborer avec nous sur GitHub
La source de ce contenu se trouve sur GitHub, où vous pouvez également créer et examiner les problèmes et les demandes de tirage. Pour plus d’informations, consultez notre guide du contributeur.