c# 获取命名空间 类名 方法名
| 分类: Winform |
public static string GetMethodInfo() { string str = ""; //取得当前方法命名空间 str += "命名空间名:"+System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Namespace + "\n"; //取得当前方法类全名 str += "类名:"+System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "\n"; //取得当前方法名 str += "方法名:"+System.Reflection.MethodBase.GetCurrentMethod().Name + "\n"; str += "\n";
StackTrace ss = new StackTrace(true); MethodBase mb = ss.GetFrame(1).GetMethod(); //取得父方法命名空间 str += mb.DeclaringType.Namespace + "\n"; //取得父方法类名 str += mb.DeclaringType.Name + "\n"; //取得父方法类全名 str += mb.DeclaringType.FullName + "\n"; //取得父方法名 str += mb.Name + "\n"; return str; }
public static void Main() { Console.WriteLine(GetMethodInfo());
Console.ReadKey(); }
c# 获取命名空间 类名 方法名的更多相关文章
- C# 反射总结 获取 命名空间 类名 方法名
一.获取 命名空间 类名 方法名 using System; using System.Collections.Generic; using System.Linq; using System.Tex ...
- c# 获取方法所在的命名空间 类名 方法名
平时我们在记录日志的时候难免会需要直接记录当前方法的路径,以便查找,但是每次都输入方法名称非常的繁琐,同时如果修改了方法名称也要去手动修改日志内容,真的是劳命伤财啊,所以有了如下方法则可解决我们的大难 ...
- C# 获取方法所在的 命名空间 类名 方法名
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- java反射查看jar包中所有的类名方法名
不反编译,不用其他工具,用java反射查看jar包中所有的类名方法名,网上很多都报错,下面这个你试试看:话不多说直接撸代码: import java.lang.reflect.Field; impor ...
- C#基础-获得当前程序的 空间名.类名.方法名
string typeName = this.GetType().ToString();//空间名.类名 string typeName = this.GetType().Name;//类名 new ...
- ThinkPHP 3.2 中获取所有函数方法名,以及注释,完整可运行
<?php namespace Home\Controller; use Common\Controller\BaseController; class AuthController exten ...
- .NET 中获取调用方法名
在写记录日志功能时,需要记录日志调用方所在的模块名.命名空间名.类名以及方法名,想到使用的是反射(涉及到反射请注意性能),但具体是哪一块儿还不了解,于是搜索,整理如下: 需要添加相应的命名空间: us ...
- PHP获取当前类名、函数名、方法名
PHP获取当前类名.方法名 __CLASS__ 获取当前类名 __FUNCTION__ 当前函数名(confirm) __METHOD__ 当前方法名 (bankcard::confirm) _ ...
- JAVA中获取当前运行的类名,方法名,行数
JAVA中获取当前运行的类名,方法名,行数 public static String getTraceInfo(){ StringBuffer sb = new StringBuffer(); Sta ...
随机推荐
- 【noi openjudge题解】最低通行费
这道题完全没有必要去计算限制时间,把时间当做一个参数来做就行了.知道了这一点之后就可以直接使用DP求解了 #include <algorithm> #include <iostrea ...
- Github命令详解
Git bash: ***创建本地版本库: $ cd d: $ mkdir git $ cd git $ mkdir test $ git init //初始化本地库 ***创建文件并添加到版本库 ...
- androidstudio下载地址
google官网地址 https://developer.android.com/studio/index.html
- mac上搭建python+selenium2的环境
1.mac默认已安装有python和easy_install 2.进入终端,使用root的权限,然后输入,回车后需要root的密码,即可安装成功,成功结果如下所示 sudo easy_install ...
- wso2 CEP集成storm实验
1.三台机子:192.168.225.1(manager,nimbus), 192.168.225.2(worker,supervisor), 192.168.225.3(worker,supervi ...
- python 基础学习3-函数
1. 函数参数-默认参数 python函数也可以跟C语言一样,在函数的形参中设定默认值. >>> def test(flag, port = 8080) ... print port ...
- SQL优化 总结 精简
索引: 考虑在 where 及 order by 涉及的列上建立索引 经常同时存取多列,且每列都含有重复值可考虑建立组合索引,且查询越频繁的字段放前面 按需使用聚集与非聚集索引,聚集不适合频繁更新.适 ...
- gerrit的merge conflict
找了很多资料,最后参考http://blog.csdn.net/w_jewelry/article/details/8123639 解决的. 先把gerrit的那几个commit abandon掉. ...
- Mac笔记本中使用postgresql
安装 brew install postgresql 安装了两个依赖包 ==> Installing dependencies for postgresql: openssl, readline ...
- 《JS权威指南学习总结--6.3删除属性》
内容要点: 一.delete运算符可以删除对象的属性.它的操作数应当是一个属性访问表达式.让人感到意外的是,delete只是断开属性和宿主对象的联系,而不会去操作属性中的属性: delete book ...