I need a way to check conditions set up in runtime.
I have classes that provide conditions created by themselves.
But I don't know how to do that.
At least I want something like that:
int x = 1;
int y = 2;
int z = 3;
string s = "(x == 1 && y == 3) || z == 3";
bool b = bool.Parse(s);
I already tried stating the conditions in a string and then convert them to a bool.
Mainly I tried using this
string s = "true || false";
and then
bool b = false;
bool.TryParse(s, out b);
or
bool b = Convert.ToBoolean(s);
The "true" or "false" statements in the string are put in later. The individual conditions are checked and being replaced with true or false.
Didn't work until now.
Edit: I am working on a Game and there are multiple objects that act according to their individual conditions. But these conditions are set up on runtime and their length and complexity is unknown before runtime. Using strings was my first attempt because i don't know how to do this. Also I know only a bit more than the basics so I don't know many methods and libraries.