您可以使用Expression<>和存储在表达式中的参数信息来获得您想要的。将表达式存储在Expression<>变量中。
int n1 = 4;
int n2 = 3;
Expression<Func<int, int, int>> exp = (arg1, arg2) => arg1 * arg2;
string expString = exp.ToString(); // (arg1, arg2) => arg1 * arg2
int startRHS = expString.IndexOf("=>") + 2; // starting index of RHS
string onlyRHS = expString.Substring(startRHS).Trim(); // arg1 * arg2
// replace args with values
string withValues = onlyRHS.Replace(exp.Parameters[0].Name, n1.ToString()); // 4 * arg2
withValues = withValues.Replace(exp.Parameters[1].Name, n2.ToString()); // 4 * 3
虽然这不是最强大的解决方案,但它适用于简单的场景。