MethodBase.IsPublicとは? わかりやすく解説

MethodBase.IsPublic プロパティ

パブリック メソッドかどうかを示す値を取得します

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

解説解説

MethodBase を取得するには、最初に型を取得します。型からメソッド取得しますメソッドから MethodBase取得しますMethodBase またはコンストラクタパブリックない場合は、それらは保護されているため簡単にアクセスできません。パブリックでないメソッドアクセスするには、GetMethod で BindingFlags マスクNonPublic設定します

使用例使用例
Class methodbase1
    
    Public Shared Function
 Main() As Integer
    
        Console.WriteLine(ControlChars.Cr + "Reflection.MethodBase")
        
        'Get the MethodBase of a method.
        
        'Get the type
        Dim MyType As Type = Type.GetType("System.MulticastDelegate")
        
        'Get and display the method
        Dim Mymethodbase As MethodBase = _
           MyType.GetMethod("RemoveImpl", BindingFlags.NonPublic)
        
        Console.Write(ControlChars.Cr _
           + "Mymethodbase = " + Mymethodbase.ToString())
        
        Dim Myispublic As Boolean
 = Mymethodbase.IsPublic
        If Myispublic Then
            Console.Write(ControlChars.Cr _
               + "Mymethodbase is a public method")
        Else
            Console.Write(ControlChars.Cr _
               + "Mymethodbase is not a public method")
        End If 
        Return 0
    End Function
End Class

' Produces the following output
' 
' Reflection.MethodBase
' Mymethodbase = System.Delegate RemoveImpl (System.Delegate)
' Mymethodbase is not a public method 
class methodbase
{
   public static int Main(string[]
 args)
   {     

      Console.WriteLine("\nReflection.MethodBase");
      
      //Get the MethodBase of a method.
 
      //Get the type
      Type MyType = Type.GetType("System.MulticastDelegate");
 
      //Get and display the method
      MethodBase Mymethodbase =
         MyType.GetMethod("RemoveImpl",BindingFlags.NonPublic);
 
      Console.Write("\nMymethodbase = " + Mymethodbase);
 
      bool Myispublic = Mymethodbase.IsPublic;
      if (Myispublic)
         Console.Write ("\nMymethodbase is a public method");
      else
         Console.Write ("\nMymethodbase is not a public method");
      
      return 0;
   }
}
/*
Produces the following output

Reflection.MethodBase
Mymethodbase = System.Delegate RemoveImpl (System.Delegate)
Mymethodbase is not a public method
*/
int main()
{
   Console::WriteLine( "\nReflection.MethodBase" );
   
   //Get the MethodBase of a method.
   //Get the type
   Type^ MyType = Type::GetType( "System.MulticastDelegate" );
   
   //Get and display the method
   MethodBase^ Mymethodbase = MyType->GetMethod( "RemoveImpl", static_cast<BindingFlags>(BindingFlags::NonPublic
 | BindingFlags::Instance) );
   Console::Write( "\nMymethodbase = {0}", Mymethodbase );
   bool Myispublic = Mymethodbase->IsPublic;
   if ( Myispublic )
      Console::Write( "\nMymethodbase is a public method"
 );
   else
      Console::Write( "\nMymethodbase is not a public method"
 );

   return 0;
}

/*
Produces the following output

Reflection.MethodBase
Mymethodbase = System.Delegate RemoveImpl (System.Delegate)
Mymethodbase is not a public method
*/
class Methodbase
{
    public static void main(String[]
 args)
    {
        Console.WriteLine("\nReflection.MethodBase");

        //Get the MethodBase of a method.
        //Get the type
        Type myType = Type.GetType("System.MulticastDelegate");

        //Get and display the method
        MethodBase myMethodBase = myType.GetMethod("RemoveImpl", 
            BindingFlags.NonPublic);
        Console.Write(("\nMymethodbase = " + myMethodBase));
        boolean myIsPublic = myMethodBase.get_IsPublic();
        if (myIsPublic) {
            Console.Write("\nmyMethodBase is a public method");
        }
        else {
            Console.Write("\nmyMethodBase is not a public
 method");
        }
    } //main
} //Methodbase

/*
 Produces the following output
 
 Reflection.MethodBase
 Mymethodbase = System.Delegate RemoveImpl (System.Delegate)
 Mymethodbase is not a public method
 */
class methodbase
{
   public static function
 Main() : void 
   {     

      Console.WriteLine("\nReflection.MethodBase");
      
      //Get the MethodBase of a method.
 
      //Get the type
      var MyType : Type = Type.GetType("System.MulticastDelegate");
 
      //Get and display the method
      var Mymethodbase : MethodBase =
         MyType.GetMethod("RemoveImpl",BindingFlags.NonPublic|BindingFlags.Instance);
 
      Console.Write("\nMymethodbase = " + Mymethodbase);
 
      var Myispublic : boolean = Mymethodbase.IsPublic;
      if (Myispublic)
         Console.Write ("\nMymethodbase is a public method");
      else
         Console.Write ("\nMymethodbase is not a public method");
   }
}
methodbase.Main();
/*
Produces the following output

Reflection.MethodBase
Mymethodbase = System.Delegate RemoveImpl (System.Delegate)
Mymethodbase is not a public method
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_MethodBase.IsPublic プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

COM オブジェクトに、IsPublic プロパティへのバージョン依存しないアクセス用意されています。

このプロパティは、CLS準拠していません。  

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

Dim instance As _MethodBase
Dim value As Boolean

value = instance.IsPublic
bool IsPublic { get; }
property bool IsPublic {
    bool get ();
}
/** @property */
boolean get_IsPublic ()

プロパティ
このメソッドパブリック場合trueそれ以外場合false

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
_MethodBase インターフェイス
_MethodBase メンバ
System.Runtime.InteropServices 名前空間


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

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

辞書ショートカット

すべての辞書の索引

「MethodBase.IsPublic」の関連用語

MethodBase.IsPublicのお隣キーワード
検索ランキング

   

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



MethodBase.IsPublicのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS