https://www.tuicool.com/articles/qIZVBre
定义一个类,下面通过表达式树从类获得函数命名
class Foo { public void KzcSevfio() { } }
static void Main(string[] args) { GetMethodName<Foo>(foo => foo.KzcSevfio()); } private static void GetMethodName<T>(Expression<Action<T>> action) where T : class { if (action.Body is MethodCallExpression expression) { Console.WriteLine(expression.Method.Name); } }