Answers for "c# get method name"

C#
2

c# get calling method name

//using System.Runtime.CompilerServices;
public void SendError(string Message, [CallerMemberName] string callerName = "") 
{ 
    Console.WriteLine(callerName + "called me."); 
} 
// You can also get the [CallerFilePath] and [CallerLineNumber].
Posted by: Guest on November-27-2020
0

get current method name c#

System.Reflection.MethodBase.GetCurrentMethod()
Posted by: Guest on September-02-2021
0

c# get executing method name

using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Reflection;

[MethodImpl(MethodImplOptions.NoInlining)]
public string GetCurrentMethod()
{
    var st = new StackTrace();
    var sf = st.GetFrame(1);

    return sf.GetMethod().Name;
}
Posted by: Guest on July-28-2021

C# Answers by Framework

Browse Popular Code Answers by Language