Search code examples
c#console.writeline

C# Console.Writeline Placeholders for function name


Are there any placeholders for the current function's name when using Console.Writeline()?


Solution

  • I believe this is what you're looking for:

    using System.Diagnostics;
    
    StackTrace stackTrace = new StackTrace();
    Console.WriteLine(stackTrace.GetFrame(1).GetMethod().Name);