Export (0) Print
Expand All
Expand Minimize

Type.GetInterfaceMap Method

Returns an interface mapping for the specified interface type.

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

public virtual InterfaceMapping GetInterfaceMap(
	Type interfaceType


Type: System.Type

The interface type to retrieve a mapping for.

Return Value

Type: System.Reflection.InterfaceMapping
An object that represents the interface mapping for interfaceType.




interfaceType is not implemented by the current type.


The interfaceType parameter does not refer to an interface.


interfaceType is a generic interface, and the current type is an array type.


interfaceType is null.


The current Type represents a generic type parameter; that is, IsGenericParameter is true.


The invoked method is not supported in the base class. Derived classes must provide an implementation.

The interface map denotes how an interface is mapped into the actual members on a class that implements that interface.

If the current Type represents a constructed generic type, type parameters are replaced by the appropriate type arguments in the elements of the InterfaceMapping returned by this method.

The following example calls the GetInterfaceMap method to determine how the IFormatProvider interface maps to CultureInfo methods, and how the IAppDomainSetup interface maps to AppDomainSetup properties. Note that, because the IAppDomainSetup interface defines a set of properties, the returned InterfaceMapping object includes separate MethodInfo objects for a property's get and set accessors.

using System;
using System.Globalization;
using System.Reflection;

public class Example
   public static void Main()
      Type[] interf = { typeof(IFormatProvider), typeof(IAppDomainSetup) };
      Type[] impl = { typeof(CultureInfo), typeof(AppDomainSetup) };

      for (int ctr = 0; ctr < interf.Length; ctr++)
         ShowInterfaceMapping(interf[ctr], impl[ctr]);

   private static void ShowInterfaceMapping(Type intType, Type implType)
      InterfaceMapping map = implType.GetInterfaceMap(intType);
      Console.WriteLine("Mapping of {0} to {1}: ", map.InterfaceType, map.TargetType);
      for (int ctr = 0; ctr < map.InterfaceMethods.Length; ctr++) {
         MethodInfo im = map.InterfaceMethods[ctr];
         MethodInfo tm = map.TargetMethods[ctr];
         Console.WriteLine("   {0} --> {1}", im.Name,tm.Name);
// The example displays the following output: 
//    Mapping of System.IFormatProvider to System.Globalization.CultureInfo: 
//       GetFormat --> GetFormat 
//    Mapping of System.IAppDomainSetup to System.AppDomainSetup: 
//       get_ApplicationBase --> get_ApplicationBase 
//       set_ApplicationBase --> set_ApplicationBase 
//       get_ApplicationName --> get_ApplicationName 
//       set_ApplicationName --> set_ApplicationName 
//       get_CachePath --> get_CachePath 
//       set_CachePath --> set_CachePath 
//       get_ConfigurationFile --> get_ConfigurationFile 
//       set_ConfigurationFile --> set_ConfigurationFile 
//       get_DynamicBase --> get_DynamicBase 
//       set_DynamicBase --> set_DynamicBase 
//       get_LicenseFile --> get_LicenseFile 
//       set_LicenseFile --> set_LicenseFile 
//       get_PrivateBinPath --> get_PrivateBinPath 
//       set_PrivateBinPath --> set_PrivateBinPath 
//       get_PrivateBinPathProbe --> get_PrivateBinPathProbe 
//       set_PrivateBinPathProbe --> set_PrivateBinPathProbe 
//       get_ShadowCopyDirectories --> get_ShadowCopyDirectories 
//       set_ShadowCopyDirectories --> set_ShadowCopyDirectories 
//       get_ShadowCopyFiles --> get_ShadowCopyFiles 
//       set_ShadowCopyFiles --> set_ShadowCopyFiles

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

© 2014 Microsoft