在c#中获取当前方法名称 [英] Getting Current Method Name in c#
本文介绍了在c#中获取当前方法名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在c#中获取当前方法名称和班级名称?
任何人都请帮帮我。谢谢你提前
Hi,
How to get the Current Method Name and class name in c#?
Anyone please help me.Thanks in Advance
推荐答案
为什么?
没关系,这并不难:
方法名称:
Why?
Never mind, it's not difficult:
Method name:
string name = MethodBase.GetCurrentMethod().Name;
班级名称:
Class name:
string name = this.GetType().Name;
我把你的问题放到谷歌这是第一个结果
http ://stackoverflow.com/questions/2652460/c-sharp-how-to-get-the-name-of-the-current-method-from-code [ ^ ]
请在提问之前进行自己的基础研究。
I put your question into google and this was the first result
http://stackoverflow.com/questions/2652460/c-sharp-how-to-get-the-name-of-the-current-method-from-code[^]
Please do your own basic research before asking a question.
这篇关于在c#中获取当前方法名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文