|
-
July 20th, 2008, 08:27 AM
#1
Tricky Problem
Hey, I have looked but couldn't find an answer to my question within the forum. Furthermore, I believe this is the correct place to ask as I am looking for a c# specific answer. If one exist please redirect me, otherwise:
I was wondering if it is at all possible to pass a segment a of code/argument to an if statement so that it can therein be evaluated. Obviously, this example won't work and I know I could just evaluate the string and make a decision from there, but I was wondering if there was any shortcut or method of passing the entire argument to be evaluated to a function that anyone knew of.
Here is essentially what I want to do:
Code:
public void OnButton1Clicked (object sender, System.EventArgs e)
{
tryStuff("x < y".);
tryStuff("x> y".);
tryStuff("x>y && x > z")
}
public void tryStuff(string s)
{
int x = 5;
int y = 10;
int z = 3;
if (s)
{
//do whatever
}
}
Thanks in advance to anyone who helps!
Last edited by cjard; July 22nd, 2008 at 07:38 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|