Export (0) Print
Expand All

MethodBase.IsSpecialName Property

Gets a value indicating whether this method has a special name.

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

public bool IsSpecialName { get; }

Property Value

Type: System.Boolean
true if this method has a special name; otherwise, false.

The SpecialName bit is set to flag members that are treated in a special way by some compilers (such as property accessors and operator overloading methods).

This example shows a use of IsSpecialName to filter internal or private members out of a list.

using System;
using System.IO;
using System.Reflection;
using System.Text;

public class Sample
    protected bool ShowMethods;
    protected StreamWriter myWriter;

    private void DumpMethods(Type aType)
        if (!ShowMethods)
        MethodInfo[] mInfo = aType.GetMethods();
        bool found = false;            
        if (mInfo.Length != 0)
            for (int i=0; i < mInfo.Length; i++)
                // Only display methods declared in this type. Also  
                // filter out any methods with special names, because these 
                // cannot be generally called by the user. That is, their  
                // functionality is usually exposed in other ways, for example, 
                // property get/set methods are exposed as properties. 
                if (mInfo[i].DeclaringType == aType && !mInfo[i].IsSpecialName)
                    found = true;
                    StringBuilder modifiers = new StringBuilder();
                    if (mInfo[i].IsStatic)   {modifiers.Append("static ");}     
                    if (mInfo[i].IsPublic)   {modifiers.Append("public ");}     
                    if (mInfo[i].IsFamily)   {modifiers.Append("protected ");}     
                    if (mInfo[i].IsAssembly) {modifiers.Append("internal ");}     
                    if (mInfo[i].IsPrivate)  {modifiers.Append("private ");}     
                    myWriter.WriteLine("{0} {1}", modifiers, mInfo[i]);
        if (!found)

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

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