Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MethodBase.IsAssembly Property

Gets a value indicating whether this method can be called by other classes in the same assembly.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public bool IsAssembly { get; }
/** @property */
public final boolean get_IsAssembly ()

public final function get IsAssembly () : boolean

Property Value

true if this method can be called by other classes in the same assembly; otherwise, false.

If set, this method can be called by other classes in the same assembly.

To get the MethodBase, first get the type. From the type, get the method. From the method, get the MethodBase. If the MethodBase or constructor is other than public, it is protected and cannot be readily accessed. To access a non-public method, set the BindingFlags mask to NonPublic in GetMethod.

The following example determines whether a specified method can be called by other classes in the same assembly, and displays the result.


using System;
using System.Reflection;

class methodbase
{
    internal void f() { }
    public static int Main(string[] args)
    { 
        Console.WriteLine ("\nReflection.MethodBase");
       
        // Get the MethodBase of two methods.
 
        // Get the types.
        Type MyType1 = Type.GetType("System.Runtime.Serialization.Formatter");
        Type MyType2 = Type.GetType("methodbase");
 
        // Get and display the methods and the IsAssembly property value.
        MethodBase Mymethodbase1 = 
            MyType1.GetMethod("WriteInt32",BindingFlags.NonPublic|BindingFlags.Instance);
        MethodBase Mymethodbase2 = 
            MyType2.GetMethod("f", BindingFlags.NonPublic|BindingFlags.Instance);
 
        Console.Write("\nMymethodbase = " + Mymethodbase1.ToString());
        if (Mymethodbase1.IsAssembly)
            Console.Write ("\nMymethodbase is an assembly method.");
        else
            Console.Write ("\nMymethodbase is not an assembly method.");
 
        Console.Write("\n\nMymethodbase = " + Mymethodbase2.ToString());
        if (Mymethodbase2.IsAssembly)
            Console.Write ("\nMymethodbase is an assembly method.");
        else
            Console.Write ("\nMymethodbase is not an assembly method.");
       
        return 0;
    }
}

import System.*;
import System.Reflection.*;

class Methodbase
{
	void F()
	{
	} //F

	public static void main(String[] args)
	{
		Console.WriteLine("\nReflection.MethodBase");

		// Get the MethodBase of two methods.
		// Get the types.
		Type myType1 = Type.GetType("System.Runtime.Serialization.Formatter");
		Type myType2 = Type.GetType("Methodbase");

		// Get and display the methods and the IsAssembly property value.
		MethodBase myMethodBase1 = myType1.GetMethod("WriteInt32", 
			BindingFlags.NonPublic | BindingFlags.Instance);
		MethodBase myMethodBase2 = myType2.GetMethod("F",
			BindingFlags.NonPublic | BindingFlags.Instance|
			BindingFlags.Public);
		Console.Write(("\nmyMethodBase = " + myMethodBase1.ToString()));
		if ( myMethodBase1.get_IsAssembly()  ) {
			Console.Write("\nmyMethodBase is an assembly method.");
		}
		else {
			Console.Write("\nmyMethodBase is not an assembly method.");
		} 
		Console.Write(("\n\nmyMethodBase = " + myMethodBase2.ToString()));
		if ( myMethodBase2.get_IsAssembly()  ) {
			Console.Write("\nmyMethodBase is an assembly method.");
		}
		else {
			Console.Write("\nmyMethodBase is not an assembly method.");
		} 

	} //main
} //methodbase

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft