How to get the current method name in C#

1 Answer

0 votes
using System;
using System.Reflection;
 
class Program
{
    public static void Test() {
        Console.WriteLine(MethodBase.GetCurrentLine().Name);
    }
     
    static void Main() {
        Test();
    }
}
 
 
 
 
/*
run:
   
Test
   
*/

 



answered Feb 4, 2024 by avibootz
edited Jun 11, 2024 by avibootz

Related questions

1 answer 152 views
1 answer 114 views
1 answer 134 views
1 answer 52 views
1 answer 117 views
...