tags

caller info

Using C# 5 caller info attributes when targeting earlier versions of the .NET framework

Caller info attributes are one of the new features of C# 5. They're attributes applied to optional method parameters that enable you to pass caller information implicitly to a method. I'm not sure that description is very clear, so an example will help you understand: static void Log( string message, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = 0) { Console.WriteLine( "[{0:g} - {1} - {2} - line {3}] {4}", DateTime.