热门关键字:  PHP  seo  Cisco  网络广告 虚拟主机 中文域名

如何得知调用当前方法的方法名?

来源:搜站长搜集 作者:未知 时间:2005-09-29 点击:
using System;
using System.Diagnostics;

namespace StackTraceTest
{
 
/// 
 
/// Class1 的摘要说明。
 
/// 

 class Class1
 
{
  
/// 
  
/// 应用程序的主入口点。
  
/// 

  [STAThread]
  
static void Main(string[] args)
  
{
   method2();
   
//输出method2
  }

  
  
static private void method1()
  
{
   StackTrace st
=new StackTrace(true);
   Console.WriteLine(st.GetFrame(
1).GetMethod().Name.ToString());   
  }


  
static private void method2()
  
{
         method1(); 
   Console.ReadLine();
  }

 }

}



最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
赞助商连接