ParameterInfo.IsOut 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,通过该值指示这是否为输出参数。
public:
 property bool IsOut { bool get(); };public bool IsOut { get; }member this.IsOut : boolPublic ReadOnly Property IsOut As Boolean属性值
如果该参数是输出参数,则为 true;否则为 false。
示例
以下示例演示如何测试 、 ParameterAttributes.Out和 ParameterAttributes.Optional 属性的方法参数ParameterAttributes.In。
该示例包含一个 DefineMethod 执行以下操作的方法:
- 创建包含 - MyType类型的动态程序集。
- MyMethod将 方法添加到- MyType。- MyMethod有三个参数。 第一个参数使用 ParameterAttributes.In定义,第二个参数使用 ParameterAttributes.Out定义,第三个参数使用 ParameterAttributes.Optional定义。
- 调用 TypeBuilder.CreateType 以完成类型。 
执行 DefineMethod后,该示例将搜索当前加载的程序集,直到找到动态程序集。 它从程序集加载 MyType ,获取 MethodInfo 方法的对象 MyMethod ,并检查参数。 该示例使用 IsIn、 IsOut和 IsOptional 属性来显示有关参数的信息。
using System;
using System.Reflection;
 class parminfo
 {
    public static void mymethod (
       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 IsOut of each parameter.
       foreach (ParameterInfo Myparam in Myarray)
       {
          Console.Write ("\nFor parameter # "   + Myparam.Position
             + ", the IsOut is - " +  Myparam.IsOut );
       }
       return 0;
    }
 }
 /*
 This code produces the following output:
 Reflection.ParameterInfo
 Mymethodbase = Void mymethod (int, System.String ByRef, System.String ByRef)
 For parameter # 0, the IsOut is - False
 For parameter # 1, the IsOut is - True
 For parameter # 2, the IsOut is - False
 */
Imports System.Reflection
Class parminfo
    
    Public Shared Sub mymethod(int1m As Integer, ByRef str2m As String, _
    ByRef str3m As String)    
        str2m = "in mymethod"
    End Sub
    
    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.CrLf + "Reflection.Parameterinfo")
        
        'Get the ParameterInfo parameter of a function.
        'Get the type.
        Dim Mytype As Type = Type.GetType("parminfo")
        
        'Get and display the method.
        Dim Mymethodbase As MethodBase = Mytype.GetMethod("mymethod")
        Console.Write(ControlChars.CrLf + "Mymethodbase = " _
           + Mymethodbase.ToString())
        
        'Get the ParameterInfo array.
        Dim Myarray As ParameterInfo() = Mymethodbase.GetParameters()
        
        'Get and display the IsOut of each parameter.
        Dim Myparam As ParameterInfo
        For Each Myparam In  Myarray
            Console.Write(ControlChars.CrLf _
               + "For parameter # " + Myparam.Position.ToString() _
               + ", the IsOut is - " + Myparam.IsOut.ToString())
        Next Myparam
        Return 0
    End Function
End Class
' This code produces the following output:
'
' Reflection.ParameterInfo
'  
' Mymethodbase = Void mymethod (Int32, System.String ByRef, System.String ByRef)
' For parameter # 0, the IsOut is - False
' For parameter # 1, the IsOut is - True
' For parameter # 2, the IsOut is - False
注解
此方法依赖于可选的元数据标志。 编译器可以插入此标志,但编译器不强制这样做。
此方法利用 Out 枚举器的 ParameterAttributes 标志。
若要获取 ParameterInfo 数组,请先获取 方法或构造函数,然后调用 MethodBase.GetParameters。