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 阅读(672) 评论(0)  编辑  收藏 所属分类: ZZ.Net

只有注册用户登录后才能发表评论。


网站导航: