Skip to content

Instantly share code, notes, and snippets.

@sholfen
Created February 17, 2015 10:19
Show Gist options
  • Save sholfen/eb53cfd53bd7382e56bb to your computer and use it in GitHub Desktop.
Save sholfen/eb53cfd53bd7382e56bb to your computer and use it in GitHub Desktop.
Print Expression Information
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace ExpressionTreeConsoleApplication
{
class Program
{
static void Main(string[] args)
{
Expression<Func<int, int>> expression3 = (n) => n + n;
PrintExpressionInfo(expression3);
}
private static void PrintExpressionInfo(LambdaExpression expression3)
{
Console.WriteLine(string.Format("Body: {0}", expression3.Body.NodeType.ToString()));
Console.WriteLine("Parameters:");
foreach (var parameter in expression3.Parameters) {
Console.WriteLine(string.Format("{0}: {1}", parameter.Name, parameter.Type.FullName));
}
Console.WriteLine(string.Format("ReturnType: {0}", expression3.ReturnType.FullName));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment