Mega Code Archive

 
Categories / C# Tutorial / LINQ
 

Cast to ParameterExpression

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using System.Xml.Linq; class Program {     static void Main(string[] args)     {         Func<int, int> func1 = x => x + 5;         var result = func1(1);         Expression<Func<int, int>> expression = func => func + 5;         var originalDelegate = expression.Compile();         var three = originalDelegate.Invoke(2);         ParameterExpression parameter = (ParameterExpression)expression.Parameters[0];         Console.WriteLine(parameter.Name);     } }