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 7175857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:23:21+00:00 2026-05-28T16:23:21+00:00

Consider this code fragment; int sum = 0; sum = Expression.Evaluate(1+1); where the value

  • 0

Consider this code fragment;

int sum = 0;
sum = Expression.Evaluate("1+1");

where the value of sum = 2

I do have an expression that will compute values but i want that expression to be build programatically then evaluate the result. I don’t have any idea what class or namespace that I will dealing with. Anyone can help me.

  • 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-05-28T16:23:22+00:00Added an answer on May 28, 2026 at 4:23 pm

    You could use Expression Trees:

    Expression trees represent code in a tree-like data structure, where
    each node is an expression, for example, a method call or a binary
    operation such as x < y.

    You can compile and run code represented by expression trees.

    • Expression Trees (C# and Visual Basic)

    • Expression Tree Basics

    Note: This problem can be solved using System.Reflection.Emit and work directly with MSIL, but the resulting code is hard to write and read.

    After a little browsing, I suggest you checkout Flee on Codeplex: Fast Lightweight Expression Evaluator :

    Flee is an expression parser and evaluator for the .NET framework. It
    allows you to compute the value of string expressions such as sqrt(a^2
    + b^2) at runtime
    . It uses a custom compiler, strongly-typed expression language, and lightweight codegen to compile expressions
    directly to IL. This means that expression evaluation is extremely
    fast and efficient.

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

Sidebar

Related Questions

Consider this code : int main() { int i(6); //this will result in i==6,but
Consider this code (Java, specifically): public int doSomething() { doA(); try { doB(); }
Consider this code: int main() { int e; prn(e); return 0; } void prn(double
Consider this code: void res(int a,int n) { printf(%d %d, ,a,n); } void main(void)
Consider this code: int x = 17; int y = 013; System.out.println(x+y = +
Consider this code sample: public class Human { public string Value { get; set;}
Consider this code: int a = 5; if (a == 5 || a ==
Consider this code: import java.util.*; class jm45 implements Comparator<jm45> { private int x; jm45(int
Consider this code: class arraytest { public static void main(String args[]) { int[] a
Consider this code: class Jm44 { public static void main(String args[]){ int []arr =

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.