Compartilhar via


Assembly.GetExportedTypes Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets the types defined in this assembly that are visible outside the assembly.

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

Syntax

'Declaration
Public Overridable Function GetExportedTypes As Type()
public virtual Type[] GetExportedTypes()

Return Value

Type: array<System.Type[]
An array of Type objects that represent the types defined in this assembly that are visible outside the assembly.

Remarks

The only types visible outside an assembly are public types and public types nested within other public types.

Examples

The following code sample defines a number of classes with various access levels, and calls GetExportedTypes to display the ones that are visible from outside the assembly.

Imports System.Reflection

Public Class Example
   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      For Each t As Type In [Assembly].GetExecutingAssembly.GetExportedTypes()
         outputBlock.Text &= t.ToString() & vbCrLf
      Next
   End Sub
End Class

Public Class PublicClass
   Public Class PublicNestedClass
   End Class

   Protected Class ProtectedNestedClass
   End Class

   Friend Class FriendNestedClass
   End Class

   Private Class PrivateNestedClass
   End Class
End Class

Friend Class FriendClass
   Public Class PublicNestedClass
   End Class

   Protected Class ProtectedNestedClass
   End Class

   Friend Class FriendNestedClass
   End Class

   Private Class PrivateNestedClass
   End Class
End Class
using System;
using System.Reflection;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      foreach (Type t in Assembly.GetExecutingAssembly().GetExportedTypes())
      {
         outputBlock.Text += t + "\n";
      }
   }
}

public class PublicClass
{
   public class PublicNestedClass { }

   protected class ProtectedNestedClass { }

   internal class FriendNestedClass { }

   private class PrivateNestedClass { }
}

internal class FriendClass
{
   public class PublicNestedClass { }

   protected class ProtectedNestedClass { }

   internal class FriendNestedClass { }

   private class PrivateNestedClass { }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.