System.Runtimer.CompilerService.Caller attributes methods and examples

 1 static void CallerDemo()
 2         {
 3             SystemRuntimeCompilerServicesCallerDemo("Test System.Runtime.CompilerServices.Caller");
 4         }
 5 
 6         static void SystemRuntimeCompilerServicesCallerDemo(string msg,
 7             [System.Runtime.CompilerServices.CallerMemberName] string memberName="",
 8             [System.Runtime.CompilerServices.CallerFilePath] string filePath="",
 9             [System.Runtime.CompilerServices.CallerLineNumber]  int lineNumber=0)
10         {
11             Console.WriteLine($"Msg={msg}");
12             Console.WriteLine($"memberName={memberName}");
13             Console.WriteLine($"filePath={filePath}");
14             Console.WriteLine($"lineNumber={lineNumber}");
15         }

 

 

posted @ 2021-03-23 15:47  FredGrit  阅读(27)  评论(0编辑  收藏  举报