Do __LINE__ __FILE__ equivalents exist in C#?

前端 未结 8 2155
说谎
说谎 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:17

    Because the stack trace contains most of what you need. It will not give you the name of the file but it will give you the class/method name. It also contains the line number. It is not neglected it is automatic. You just need to throw an exception like you do it in Java

提交回复
热议问题