做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

在.NET中取得代碼行數的方法

來源:懂視網 責編:小采 時間:2020-11-27 22:39:01
文檔

在.NET中取得代碼行數的方法

在.NET中取得代碼行數的方法:文章目的 介紹在.NET中取得代碼行數的方法 代碼 代碼如下:[STAThread] static void Main(string[] args) { ReportError(Yay!); } static private void ReportError(string Message) { StackFrame CallSt
推薦度:
導讀在.NET中取得代碼行數的方法:文章目的 介紹在.NET中取得代碼行數的方法 代碼 代碼如下:[STAThread] static void Main(string[] args) { ReportError(Yay!); } static private void ReportError(string Message) { StackFrame CallSt

文章目的

介紹在.NET中取得代碼行數的方法

代碼
代碼如下:


[STAThread]
static void Main(string[] args)
{
ReportError("Yay!");
}

static private void ReportError(string Message)
{
StackFrame CallStack = new StackFrame(1, true);
Console.Write("Error: " + Message + ", File: " + CallStack.GetFileName() + ", Line: " + CallStack.GetFileLineNumber());
}

StackFrame(Int32, Boolean) 初始化與當前堆棧幀之上的幀對應的 StackFrame 類的新實例,可以選擇捕獲源信息。

GetFileName :獲取包含所執行代碼的文件名。 該信息通常從可執行文件的調試符號中提取。

GetMethod :獲取在其中執行幀的方法。

GetFileLineNumber :獲取文件中包含所執行代碼的行號。 該信息通常從可執行文件的調試符號中提取。

利用Exception(例外)的StackTrace類
代碼如下:


try
{
throw new Exception();
}
catch (Exception ex)
{
// Get stack trace for the exception with source file information
var st = new StackTrace(ex, true);
// Get the top stack frame
var frame = st.GetFrame(0);
// Get the line number from the stack frame
var line = frame.GetFileLineNumber();
}

.NET4.5 新方法
代碼如下:

static void SomeMethodSomewhere()
{
ShowMessage("Boo");
}
...
static void ShowMessage(string message,
[CallerLineNumber] int lineNumber = 0,
[CallerMemberName] string caller = null)
{
MessageBox.Show(message + " at line " + lineNumber + " (" + caller + ")");
}

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

在.NET中取得代碼行數的方法

在.NET中取得代碼行數的方法:文章目的 介紹在.NET中取得代碼行數的方法 代碼 代碼如下:[STAThread] static void Main(string[] args) { ReportError(Yay!); } static private void ReportError(string Message) { StackFrame CallSt
推薦度:
標簽: 方法 代碼 取得
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 黄大仙区| 徐汇区| 凤阳县| 固原市| 北票市| 富川| 永清县| 南漳县| 工布江达县| 崇义县| 枞阳县| 高青县| 韩城市| 古田县| 九江市| 绵阳市| 漠河县| 邢台县| 松桃| 湘潭市| 安仁县| 上犹县| 交口县| 凤山市| 岐山县| 怀集县| 全南县| 巴马| 双峰县| 六安市| 清原| 靖西县| 泰州市| 米泉市| 广东省| 南投市| 肇庆市| 探索| 东兴市| 印江| 柞水县|