當前位置: 首頁>>代碼示例>>C#>>正文


C# MethodBase.IsSpecialName屬性代碼示例

本文整理匯總了C#中System.Reflection.MethodBase.IsSpecialName屬性的典型用法代碼示例。如果您正苦於以下問題:C# MethodBase.IsSpecialName屬性的具體用法?C# MethodBase.IsSpecialName怎麽用?C# MethodBase.IsSpecialName使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。


在下文中一共展示了MethodBase.IsSpecialName屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DumpMethods

//引入命名空間
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)
            return;
        MethodInfo[] mInfo = aType.GetMethods();
        myWriter.WriteLine("Methods"); 
        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)
        {
            myWriter.WriteLine("(none)");
        }
    }
}
開發者ID:.NET開發者,項目名稱:System.Reflection,代碼行數:46,代碼來源:MethodBase.IsSpecialName


注:本文中的System.Reflection.MethodBase.IsSpecialName屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。