How can I get the name of the first method called from an expression in C #? Something like the fictional MethodUtils.NameFromExpression () below:
Expression<Action<string>> expr = s => s.Trim(); Assert.AreEqual("Trim", MethodUtils.NameFromExpression(expr));
Ideally, any util method would be written / overloaded so that it can accept expressions for any of the Action or Func delegation types.
Thanks in advance.
UPDATE
I found the answer (see below), but would still like to know if this is a good solution or if there is a way to do this in BCL.
c # lambda linq
chillitom
source share