public static string ExprToString(Expression expr) { Contract.Requires(expr != null); using (var wr = new System.IO.StringWriter()) { var pr = new Printer(wr); pr.PrintExpression(expr, false); return wr.ToString(); } }
private static int GetExpressionLength(Expression expr) { var sw = new StringWriter(); var printer = new Printer(sw); printer.PrintExpression(expr, false); return sw.ToString().Length; }