jinfeng_wang

          G-G-S,D-D-U!

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks
          class SomeClass
          {
          public int DoSomething()
          {
          ReportError("Here's an error message");
          return 0;
          }

          private void ReportError(string Message)
          {
          // Get the frame one step up the call tree
          StackFrame CallStack = new StackFrame(1, true);

          // These will now show the file and line number of the ReportError
          call in the DoSomething() method
          string SourceFile = CallStack.GetFileName(),
          int SourceLine = CallStack.GetFileLineNumber(),
          MyWriteToFile("Error: " + Message + " - File: " + SourceFile + "
          Line: " + SourceLine.ToString());
          }
          }
          posted on 2007-07-03 14:16 jinfeng_wang 閱讀(711) 評論(0)  編輯  收藏 所屬分類: ZZ.Net
          主站蜘蛛池模板: 施秉县| 潜江市| 乌拉特中旗| 绥德县| 宜丰县| 岗巴县| 财经| 新津县| 易门县| 民乐县| 进贤县| 新建县| 大名县| 左云县| 锦州市| 郯城县| 霍山县| 沛县| 兴海县| 南部县| 万安县| 木兰县| 白银市| 杭锦旗| 香格里拉县| 昭平县| 双辽市| 芒康县| 东阿县| 二连浩特市| 任丘市| 灌南县| 西昌市| 彰化市| 大庆市| 安图县| 浦东新区| 阳新县| 钟山县| 兴业县| 宜宾市|