MethodAttributes 列挙体とは? わかりやすく解説

MethodAttributes 列挙体

メソッドの属性について使用するフラグを指定します。これらのフラグは corhdr.h ファイルで定義されています。

この列挙体には、メンバ値のビットごとの組み合わせを可能にする FlagsAttribute 属性が含まれています。

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

<SerializableAttribute> _
<FlagsAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration MethodAttributes
Dim instance As MethodAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum MethodAttributes
[SerializableAttribute] 
[FlagsAttribute] 
[ComVisibleAttribute(true)] 
public enum class MethodAttributes
/** @attribute SerializableAttribute() */ 
/** @attribute FlagsAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum MethodAttributes
SerializableAttribute 
FlagsAttribute 
ComVisibleAttribute(true) 
public enum MethodAttributes
メンバメンバ
 メンバ名説明
.NET Compact Framework によるサポートAbstractクラスがこのメソッドの実装を提供しないことを示します。 
.NET Compact Framework によるサポートAssemblyこのアセンブリのすべてのクラスがメソッドにアクセスできることを示します。 
CheckAccessOnOverrideアクセス可能な場合に限りオーバーライドできるメソッドであることを示します。 
.NET Compact Framework によるサポートFamANDAssemこの型と、このアセンブリ内の派生した型のメンバだけが、メソッドにアクセスできることを示します。 
.NET Compact Framework によるサポートFamilyこのクラスとこのクラスの派生クラスのメンバだけがメソッドにアクセスできることを示します。 
.NET Compact Framework によるサポートFamORAssemこのアセンブリ内のすべてのクラスと、任意の場所にある派生クラスからメソッドにアクセスできることを示します。 
.NET Compact Framework によるサポートFinalメソッドをオーバーライドできないことを示します。 
.NET Compact Framework によるサポートHasSecurityメソッドにセキュリティが関連付けられていることを示します。Runtime 専用に予約されているフラグです。 
.NET Compact Framework によるサポートHideBySigメソッドが名前とシグネチャで隠ぺいされることを示します。このフラグが設定されていない場合は、メソッドは名前だけで隠ぺいされます。 
.NET Compact Framework によるサポートMemberAccessMaskアクセシビリティに関する情報を取得します。 
.NET Compact Framework によるサポートNewSlotメソッドが vtable で必ず新しいスロットを取得することを示します。 
.NET Compact Framework によるサポートPinvokeImplメソッドの実装が PInvoke (Platform Invocation Services) を通じて転送されることを示します。 
.NET Compact Framework によるサポートPrivate現在のクラスだけからメソッドにアクセスできることを示します。 
.NET Compact Framework によるサポートPrivateScopeメンバを参照できないことを示します。 
.NET Compact Framework によるサポートPublicこのオブジェクトがスコープ内に入っている全オブジェクトからメソッドにアクセスできることを示します。 
.NET Compact Framework によるサポートRequireSecObjectメソッドが、セキュリティ コードを含んでいる別のメソッドを呼び出すことを示します。Runtime 専用に予約されているフラグです。 
.NET Compact Framework によるサポートReservedMaskRuntime 専用に予約されているフラグを示します。 
.NET Compact Framework によるサポートReuseSlotメソッドが、vtable の既存のスロットを再利用することを示します。これが既定の動作です。 
.NET Compact Framework によるサポートRTSpecialName共通言語ランタイムが名前のエンコーディングを確認することを示します。 
.NET Compact Framework によるサポートSpecialNameメソッドが特別であることを示します。メソッドが特別である理由は名前で説明します。 
.NET Compact Framework によるサポートStaticメソッドが型で定義されていることを示します。このフラグが設定されていない場合、メソッドはインスタンスごとに定義されます。 
.NET Compact Framework によるサポートUnmanagedExportマネージ メソッドが、サンクによってアンマネージ コードにエクスポートされることを示します。 
.NET Compact Framework によるサポートVirtualメソッドが仮想メソッドであることを示します。 
.NET Compact Framework によるサポートVtableLayoutMaskvtable 属性を取得します。 
使用例使用例

指定したメソッドの属性を表示する例を次に示します。

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Class AttributesSample

    Public Sub Mymethod(ByVal
 int1m As Integer, ByRef
 str2m As String, ByRef str3m As String)
        str2m = "in Mymethod"
    End Sub 'Mymethod


    Public Shared Function
 Main(ByVal args() As String)
 As Integer
        Console.WriteLine("Reflection.MethodBase.Attributes Sample")

        ' Get the type of a chosen class.
        Dim MyType As Type = Type.GetType("AttributesSample")

        ' Get the method Mymethod on the type.
        Dim Mymethodbase As MethodBase = MyType.GetMethod("Mymethod")

        ' Display the method name and signature.
        Console.WriteLine("Mymethodbase = {0}", Mymethodbase)

        ' Get the MethodAttribute enumerated value.
        Dim Myattributes As MethodAttributes
 = Mymethodbase.Attributes

        ' Display the flags that are set.
        PrintAttributes(GetType(System.Reflection.MethodAttributes),
 CInt(Myattributes))
        Return 0
    End Function 'Main

    Public Shared Sub PrintAttributes(ByVal
 attribType As Type, ByVal iAttribValue As
 Integer)
        If Not attribType.IsEnum Then
            Console.WriteLine("This type is not an enum.")
            Return
        End If
        Dim fields As FieldInfo() = attribType.GetFields((BindingFlags.Public
 Or BindingFlags.Static))
        Dim i As Integer
        For i = 0 To fields.Length - 1
            Dim fieldvalue As Integer
 = CType(fields(i).GetValue(Nothing), Int32)
            If (fieldvalue And iAttribValue)
 = fieldvalue Then
                Console.WriteLine(fields(i).Name)
            End If
        Next i
    End Sub 'PrintAttributes
End Class 'AttributesSample
using System;
using System.Reflection;
 
class AttributesSample
{
    public void Mymethod (int
 int1m, out string str2m, ref string str3m)
    {
        str2m = "in Mymethod";
    }
 
    public static int Main(string[]
 args)
    {      
        Console.WriteLine ("Reflection.MethodBase.Attributes Sample");
       
        // Get the type of the chosen class.
        Type MyType = Type.GetType("AttributesSample");
 
        // Get the method Mymethod on the type.
        MethodBase Mymethodbase = MyType.GetMethod("Mymethod");
 
        // Display the method name and signature.
        Console.WriteLine("Mymethodbase = " + Mymethodbase);
 
        // Get the MethodAttribute enumerated value.
        MethodAttributes Myattributes = Mymethodbase.Attributes;
 
        // Display the flags that are set.
        PrintAttributes(typeof(System.Reflection.MethodAttributes), (int)
 Myattributes);
        return 0;
    }
 
 
    public static void PrintAttributes(Type
 attribType, int iAttribValue)
    {
        if (!attribType.IsEnum) {Console.WriteLine("This
 type is not an enum."); return;}
 
        FieldInfo[] fields = attribType.GetFields(BindingFlags.Public | BindingFlags.Static);
        for (int i = 0; i < fields.Length;
 i++)
        {
            int fieldvalue = (Int32)fields[i].GetValue(null);
            if ((fieldvalue & iAttribValue) == fieldvalue)
            {
                Console.WriteLine(fields[i].Name);
            }
        }
    }
}
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;

public ref class AttributesSample
{
public:
   void Mymethod( int int1m, [Out]interior_ptr<String^>
 str2m, interior_ptr<String^> str3m )
   {
       *str2m = "in Mymethod";
   }
};

void PrintAttributes( Type^ attribType, int
 iAttribValue )
{
   if (  !attribType->IsEnum )
   {
      Console::WriteLine( "This type is not an enum." );
      return;
   }

   array<FieldInfo^>^fields = attribType->GetFields( static_cast<BindingFlags>(BindingFlags::Public
 | BindingFlags::Static) );
   for ( int i = 0; i < fields->Length;
 i++ )
   {
      int fieldvalue = safe_cast<Int32>(fields[ i ]->GetValue(
 nullptr ));
      if ( (fieldvalue & iAttribValue) == fieldvalue )
      {
         Console::WriteLine( fields[ i ]->Name );
      }
   }
}

int main()
{
   Console::WriteLine( "Reflection.MethodBase.Attributes Sample" );

   // Get the type of the chosen class.
   Type^ MyType = Type::GetType( "AttributesSample" );

   // Get the method Mymethod on the type.
   MethodBase^ Mymethodbase = MyType->GetMethod( "Mymethod" );

   // Display the method name and signature.
   Console::WriteLine( "Mymethodbase = {0}", Mymethodbase );

   // Get the MethodAttribute enumerated value.
   MethodAttributes Myattributes = Mymethodbase->Attributes;

   // Display the flags that are set.
   PrintAttributes( System::Reflection::MethodAttributes::typeid, (int)Myattributes
 );
   return 0;
}
import System.*;
import System.Reflection.*;

class AttributesSample
{   
    public void MyMethod(int
 int1m,
        /** @ref
         */ String str2m,
        /** @ref
         */ String str3m)
    {
        str2m = "in MyMethod";
    } //MyMethod

    public static void main(String[]
 args)
    {
        Console.WriteLine("Reflection.MethodBase.Attributes Sample");

        // Get the type of the chosen class.
        Type myType = Type.GetType("AttributesSample");

        // Get the method MyMethod on the type.
        MethodBase myMethodBase = myType.GetMethod("MyMethod");

        // Display the method name and signature.
        Console.WriteLine(("myMethodBase = " + myMethodBase));

        // Get the MethodAttribute enumerated value.
        MethodAttributes myAttributes = myMethodBase.get_Attributes();

        // Display the flags that are set.
        PrintAttributes(System.Reflection.MethodAttributes.class.ToType()
,
            (int)(myAttributes));
    } //main

    public static void PrintAttributes(Type
 attribType, int iAttribValue)
    {
        if (!(attribType.get_IsEnum())) {
            Console.WriteLine("This type is not an enum.");
            return ;
        }
        FieldInfo fields[] = attribType.GetFields(
            (BindingFlags.Public | BindingFlags.Static));
        for(int i=0; i < fields.length;
 i++) {
            int fieldValue = (int)((Int32)(fields[i].GetValue(null)));
            if ((fieldValue & iAttribValue) == fieldValue
  ) {
                Console.WriteLine(fields[i].get_Name());
            }
        } 
    } //PrintAttributes
} //AttributesSample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からMethodAttributes 列挙体を検索した結果を表示しています。
Weblioに収録されているすべての辞書からMethodAttributes 列挙体を検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMethodAttributes 列挙体 を検索

英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「MethodAttributes 列挙体」の関連用語

MethodAttributes 列挙体のお隣キーワード
検索ランキング

   

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



MethodAttributes 列挙体のページの著作権

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

©2026 GRAS Group, Inc.RSS