Whats the equivalent of __LINE__ and __FILE__ in C# I thought this hot-button issue would have been answered by now. But no one seems to have a good answer for this. I would love to see a solution which presents no runtime overhead. What about C# 3.0 does it address this issue

Whats the equivalent of __LINE__ and __FILE__ in C#
Jazza23
OmegaMan
jdoug
If you want to use it for exception handling you can find the filename and line number in the the StackTrace property of the exception:
silentC
Nfrf
Without the line numbers and the source file names I surely would have a hard time mapping the log records to the point of origin in the source code. Also the "mapping" cannot be automated.
By the way - can you take minidumps of C# applications and then debug them using .Net Debuggers (say VS2005)
I would have raised this as a bug against C#!! But I think its up to the developers of C# to decide what goes and does not go into the language. If any body from the C# team is listening please consider this as a request. I think it wont cost you much to add this feature (in terms of runtime costs as well as implementation costs)
Alexander Marinov
1) C# doesn't need (much) debugging
OR
2) There are alternatives to using __LINE__ and __FILE__. If yes then how do I generate logs from my C# code which provide source line no and source file information
PS: My initial conditions still stand - no runtime overhead please. For example please don't suggest stack walking (in any case the required info is available only in debug builds)
Alan M Dunsmuir
arkiboys