Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8770757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:37:15+00:00 2026-06-13T17:37:15+00:00

Expression trees purpose: Expression tree must be compiled before it can be used. This

  • 0

Expression trees purpose:

Expression tree must be
compiled before it can be used. This is because expression tree is
actually a data structure, not compiled code. Why? Because this code
is expected to be used across wire, or – in other words – in other
processes
(running possibly on other computers).

From: http://geekswithblogs.net/Martinez/archive/2009/06/29/understanding-expression-trees.aspx

What is the difference between ‘Data Structure’ and ‘compiled code’; How does comipled code looks like in C# ?! By this article I understand that every line that does not contain Array or List is compiled code (Like: "Human H1=new Human(18);").

Please dont expain me what are Expression trees with examples, I want a clear answer about this question.

Thank you for your time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:37:17+00:00Added an answer on June 13, 2026 at 5:37 pm

    You cannot execute an expression tree without compiling it first because expression trees serve a different purpose: they work as flexible blueprints for executable code, rather than being the the executable code itself (with is rather inflexible).

    An expression tree is a data structure that describes code (compiled or not) at an abstraction level that is higher than the code itself. Unlike code, the data structure can be manipulated to make a different structure that describes some other piece of code. Unlike the data structure, the code can be evaluated to produce a result.

    Consider this example:

    Expression p1 = Expression.Parameter(typeof(int), "a");
    Expression p2 = Expression.Parameter(typeof(int), "b");
    Expression expr = Expression.Add(p1, p2);
    

    It shows an expression expr being created, describing a simple expression tree a+b. At this point, we have a tree-like data structure with three nodes – two nodes representing parameters, and one node representing addition. We can do lots of things with the expression tree, such as examining its content, finding its return type, and so on. We can even manipulate its structure to make other expressions based on it: for example, we could add a third parameter, and make a+b+c, like this:

    Expression p3 = Expression.Parameter(typeof(int), "c");
    expr = Expression.Add(expr, p3);
    

    One thing we cannot do, however, is pass it two integer values and obtain their sum: expression trees do not provide methods for evaluating them. In order to do that, you need real code, not a description of code.

    Expression trees provide a way to convert descriptions of code into code by way of compiling them. Once you make an expression tree into lambda and call the Compile() method on it, you get back a compiled CIL code that looks like this:

    ldarg.0
    ldarg.1
    add
    ret
    

    This code can be passed two values for evaluation, and it will return the sum to you. However, some information is lost in translation: specifically, the names of parameters a and b are no longer there in the compiled code: they are not necessary to perform calculations, so they have been eliminated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Expression trees represent code in a tree-like data structure, where each node is an
How can I do something like this using Expression trees : customers.Where(c => c.Name
I'm building a LINQ expression tree but it won't compile because allegedly the local
I am attempting to dynamically build up an expression tree so that I can
Can the compiler/runtime reorder or inline expression trees? If I got the following code:
http://geekswithblogs.net/Martinez/archive/2009/06/29/understanding-expression-trees.aspx By reading this article that expline what are Expression trees and what they
Are LINQ expression trees proper trees, as in, graphs (directed or not, wikipedia does
This is a learning exercise in expression trees. I have this working code: class
I have read much about lambda,expression trees amd sort of compiled stuff... now where
I must admit that I'm absolutely new to Expression Trees in C#, but currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.