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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:59:43+00:00 2026-06-13T02:59:43+00:00

Given a dynamic if statement in a String is there a method in .net

  • 0

Given a dynamic if statement in a String is there a method in .net to evaluate and return the correct result.

I.E.

    static void Main(string[] args)
    {
        String a = "if(\"Alex\" == \"Alex\"){return 1;}else{return 0;}";
        passThroughTest.Program.evalStatement(a);
    }
    public static void evalStatement(String statement)
    {

        //Evaluation of Statement

     }

This isn’t perfect but in this case the end result would be a 1. This seems ‘stupid’ from this point of view, but its for a more complex engine which needs to draw on similar syntax to evaluate.

Am I at a point where I need to write a parser of some sort and evaluate the statements…?

Thanks for your help!

  • 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-13T02:59:44+00:00Added an answer on June 13, 2026 at 2:59 am
    • You can use javascript.net

      Sample code from their website:

      // Initialize a context
      using (JavascriptContext context = new JavascriptContext()) {
      
          // Setting external parameters for the context
          context.SetParameter("console", new SystemConsole());
          context.SetParameter("message", "Hello World !");
          context.SetParameter("number", 1);
      
          // Script
          string script = @"
              var i;
              for (i = 0; i < 5; i++)
                  console.Print(message + ' (' + i + ')');
              number += i;
          ";
      
          // Running the script
          context.Run(script);
      
          // Getting a parameter
          Console.WriteLine("number: " + context.GetParameter("number"));
      }
      
    • Or use C# expression tree, see Building Expression Evaluator with Expression Trees

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

Sidebar

Related Questions

Given the new dynamic support in C# 4, is it possible to write a
Given an NSMutableArray of dynamic CGPoint s, what is the fastest and most efficient
I am trying to generate dynamic menu according to the user permission given with
Which C++ cross-platform GUI toolkit gives smallest footprint with both static and dynamic builds?
Given this method to work on a HTML page in a webbrowser: bool semaphoreForDocCompletedEvent;
I have an excel sheet that is loaded with a dynamic result set of
#include<stdio.h> #include<string.h> char *y; y=(char *)malloc(40); // gives an error here int main() {
I want to create dynamic conditional statement in java following are my expression in
I have this issue, I want to have a dynamic if statement and it
I have dynamic number of checkboxes in jsp page as given below. <s:iterator value=details

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.