C#: Is there a way to use expressions as a variable/parameter?
<p>I'd like to know if it is possible to use an expression as a variable/parameter in C#.  I would like to do something like this:</p>

<pre><code>int x = 0;
public void g()
{
   bool greaterThan = f("x&gt;2");
   bool lessThan = f("x&lt;2");
}
public bool f(Expression expression)
{
   if(expression)
       return true;
   else
       return false;
}
</code></pre>

<p>Here's what I don't want to do:</p>

<pre><code>int x = 0;
public void g()
{
    bool greaterThan = f(x, '&lt;', 2);
}

public bool f(int x, char c, int y)
{
    if(c == '&lt;')
       return x &lt; y;
    if(c == '&gt;')
       return x &gt; y;
}
</code></pre>

<p>Really what I'm getting at is a way to get around using a switch or series of if statements for each of: &lt; > &lt;= >= == !=.  Is there a way to do it?</p>

<p>Edit: Suppose that the expression is a string, like "x &lt; 2".  Is there a way to go from the string to a predicate without using a series of if statements on the condition?</p>
