Do __LINE__ __FILE__ equivalents exist in C#?

前端 未结 8 2127
说谎
说谎 2020-12-01 03:53

For logging purposes

__LINE__ 
__FILE__ 

were my friends in C/C++. In Java to get that information I had to throw an exception and catch

8条回答
  •  粉色の甜心
    2020-12-01 04:11

    Here's a way to get the line number: http://askville.amazon.com/SimilarQuestions.do?req=line-numbers-stored-stack-trace-C%2523-application-throws-exception

    If you use log4net, you can get the line number and file name in your logs, but:

    • it can decrease your app. performance
    • you have to have .PDB files together with your assemblies.

提交回复
热议问题