ParameterInfo.Attributes プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ParameterInfo.Attributes プロパティの意味・解説 

ParameterInfo.Attributes プロパティ

このパラメータ属性取得します

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable ReadOnly
 Property Attributes As ParameterAttributes
Dim instance As ParameterInfo
Dim value As ParameterAttributes

value = instance.Attributes
public virtual ParameterAttributes Attributes { get;
 }
public:
virtual property ParameterAttributes Attributes {
    ParameterAttributes get ();
}
/** @property */
public ParameterAttributes get_Attributes ()
public function get Attributes
 () : ParameterAttributes

プロパティ
このパラメータ属性を表す ParameterAttributes オブジェクト

解説解説

AttrsImpl メソッド利用します

ParameterInfo 配列取得するには、最初にメソッドまたはコンストラクタ取得してから MethodBase.GetParameters を呼び出します。

使用例使用例
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class MyClass1
   
   Public Function MyMethod(i As
 Integer, ByRef j As Short,
 ByRef k As Long) As Integer
      j = 2
      Return 0
   End Function 'MyMethod
End Class 'MyClass1

Public Class ParameterInfo_Attributes
   
   Public Shared Sub Main()
      ' Get the type. 
      Dim myType As Type = GetType(MyClass1)
      ' Get the method named 'MyMethod' from the type.
      Dim myMethodBase As MethodBase = myType.GetMethod("MyMethod")
      ' Get the parameters associated with the method.
      Dim myParameters As ParameterInfo() =
 myMethodBase.GetParameters()
      Console.WriteLine(ControlChars.Cr + "The method {0} has
 the {1} parameters :", "ParameterInfo_Example.MyMethod",
 myParameters.Length)
      ' Print the attributes associated with each of the parameters.
      Dim i As Integer
      For i = 0 To myParameters.Length - 1
         Console.WriteLine(ControlChars.Tab + "The {0} parameter
 has the attribute : {1}", i + 1, myParameters(i).Attributes)
      Next i
   End Sub 'Main
End Class 'ParameterInfo_Attributes
using System;
using System.Reflection;
public class MyClass1
{
   public int MyMethod( int
 i, out short j, ref long k)
   {
      j = 2;
      return 0;
   }  
}

public class ParameterInfo_Attributes
{   
   public static void Main()
   {
      // Get the type. 
      Type myType = typeof(MyClass1);
      // Get the method named 'MyMethod' from the type.
      MethodBase myMethodBase = myType.GetMethod("MyMethod");
      // Get the parameters associated with the method.
      ParameterInfo[] myParameters = myMethodBase.GetParameters();
      Console.WriteLine("\nThe method {0} has the {1} parameters :", 
                          "ParameterInfo_Example.MyMethod", myParameters.Length);
      // Print the attributes associated with each of the parameters.
      for(int i = 0; i < myParameters.Length;
 i++)
         Console.WriteLine("\tThe {0} parameter has the attribute : {1}",
 
                                             i + 1, myParameters[i].Attributes);
   }
}
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;
public ref class MyClass1
{
public:
   int MyMethod( int i, [Out]short * j, long
 * k )
   {
       *j = 2;
      return 0;
   }

};

void main()
{
   // Get the type. 
   Type^ myType = MyClass1::typeid;

   // Get the method named 'MyMethod' from the type.
   MethodBase^ myMethodBase = myType->GetMethod( "MyMethod" );

   // Get the parameters associated with the method.
   array<ParameterInfo^>^myParameters = myMethodBase->GetParameters();
   Console::WriteLine( "\nThe method {0} has the {1} parameters :", "ParameterInfo_Example::MyMethod",
 myParameters->Length );

   // Print the attributes associated with each of the parameters.
   for ( int i = 0; i < myParameters->Length;
 i++ )
      Console::WriteLine( "\tThe {0} parameter has the attribute : {1}",
 i + 1, myParameters[ i ]->Attributes );
}
import System.*;
import System.Reflection.*;

public class MyClass1
{
    public int MyMethod(int
 i, /** @ref */short j, /** @ref */ long k)
    {
        j = 2;
        return 0;
    } //MyMethod
} //MyClass1

public class ParameterInfo_Attributes
{
    public static void main(String[]
 args)
    {
        // Get the type. 
        Type myType = MyClass1.class.ToType();
        // Get the method named 'MyMethod' from the type.
        MethodBase myMethodBase = myType.GetMethod("MyMethod");
        // Get the parameters associated with the method.
        ParameterInfo myParameters[] = myMethodBase.GetParameters();
        Console.WriteLine("\nThe method {0} has the {1} parameters :",
 
            "ParameterInfo_Example.MyMethod", 
            (Int32)myParameters.get_Length());
        // Print the attributes associated with each of the parameters.
        for (int i = 0; i < myParameters.get_Length();
 i++) {
            Console.WriteLine("\tThe {0} parameter has the attribute : {1}"
,
                (Int32)(i + 1), myParameters[i].get_Attributes());
        }
    } //main
} //ParameterInfo_Attributes
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ParameterInfo クラス
ParameterInfo メンバ
System.Reflection 名前空間
ParameterAttributes 列挙



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ParameterInfo.Attributes プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ParameterInfo.Attributes プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS