C# 里怎樣得到當前執(zhí)行的函數(shù)名,當前代碼行,源代碼文件名
來源:易賢網(wǎng) 閱讀:1576 次 日期:2015-03-23 15:51:00
溫馨提示:易賢網(wǎng)小編為您整理了“C# 里怎樣得到當前執(zhí)行的函數(shù)名,當前代碼行,源代碼文件名”,方便廣大網(wǎng)友查閱!

得到函數(shù)名:

System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();

this.Text = st.GetFrame(0).ToString();

得到代碼行,源代碼文件名:

StackTrace st = new StackTrace(new StackFrame(true));

Console.WriteLine(" Stack trace for current level: {0}", st.ToString());

StackFrame sf = st.GetFrame(0);

Console.WriteLine(" File: {0}", sf.GetFileName());

Console.WriteLine(" Method: {0}", sf.GetMethod().Name);

Console.WriteLine(" Line Number: {0}", sf.GetFileLineNumber());

Console.WriteLine(" Column Number: {0}", sf.GetFileColumnNumber());

更多信息請查看IT技術專欄

更多信息請查看技術文章
下一篇:Fastcgi是什么
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)