-2

Let's say I have 3 strings

string a = "Dog";
string b = "==";
string c = "cat";

How could I use them in an If Statement as follows

if (a b c)
{

     return true;

}else{

     return false;

}

The idea behind this low code, or a visual coding platform where a user enters the 3 portions

Condition 1
The Operator
Condition 2

And returns true or false

3

2 Answers 2

2

You can write a possible operator in if-else or switch operator, and then you can compare with your user input, and according to that, you can perform your operation.

For Example:-

If (b == "==")
{
 return a==c;
}
Sign up to request clarification or add additional context in comments.

Comments

0

In simple words: You want to create an expression (in specific, a bool-result-expression)

Fast way:

string a;
string b;
string c;

bool? result = null; //I prefer nullable in case of absence of match
if(b == "=="){
    result = Equals(a, c); //This is for equality, you can create your own methods and check what you want
}

Correct way: use an expression parser. There are a lot of different options in the community, well tested and continued.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.