vedranvinko

caller information attributes

Oct 9th, 2019
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. using System;
  2. using System.Runtime.CompilerServices;
  3.                    
  4. public class Program
  5. {
  6.     public static void Main()
  7.     {
  8.        
  9.     }
  10.    
  11.     public static void Log(string text, [CallerMemberName] string memberName ="", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
  12.     {
  13.         Console.WriteLine("{text} - {sourceFilePath}/{memberName} (line {sourceLineNumber})");
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment