Check if a Type is nested and visible only within its own assembly in CSharp

Description

The following code shows how to check if a Type is nested and visible only within its own assembly.

Example


// ww  w.  ja v  a  2  s.  c  om
using System;

class MyClassA
{
    internal class MyClassB
    {
    }
}
class MyTestClass
{
    public static void Main(string[] args)
    {  
        Type myTypeB = typeof(MyClassA.MyClassB);
        Console.WriteLine("\nThe IsNestedAssembly property value of MyClassB is {0}.", myTypeB.IsNestedAssembly.ToString());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Reflection »




Array
Constructor
Event
Field
Interface
Method
Properties
Type