MethodBase.IsPublic プロパティ
アセンブリ: 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 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_MethodBase.IsPublic プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMethodBase.IsPublicを検索する場合は、下記のリンクをクリックしてください。

- MethodBase.IsPublicのページへのリンク