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 it. Why are these old standbys so neglected in the modern programming languages? There is something magical about their simplicity.
It is uglier, but you can do something like this in C# using the StackTrace and StackFrame classes:
Of course, this comes with some overhead.