The way to do this is to attribute a parameter on the method with the CallerLineNumberAttribute
and provide it with a default value. C# will then fill it in with the line number of the caller
void Method(string message, [CallerLineNumber] int lineNumber = 0) {
...
}
Method("foo"); // C# will insert the line number here
Note that there are actually a set of related attributes here that might interest you. Here is a sample
public void TraceMessage(string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
Full Documentation: http://msdn.microsoft.com/en-us/library/hh534540.aspx
Note: This requires the C# 5.0 compiler which is included in VS 2013.