Table Driven Method issue
<p>I am writing a table driven method in C#. I have a dictionary of this signature:</p>

<pre><code>Diction&lt;Func&lt;string, bool&gt;, Func&lt;string&gt;&gt;
</code></pre>

<p>So it will take a string as a parameter and let me execute a method which returns a bool on the string (eg string.Length > 5). The value corresponds to methods which return a string.</p>

<p>But the method which does this takes a func as a parameter. I want to change this so it takes a string but then it looks at the string's length and gets the right value from the dictionary.</p>

<p>Something like this:</p>

<pre><code>dict[s.Length]; Or dict[s]; // Where s is a string
</code></pre>

<p>If it is greater than 5, it gets the Func which runs the method for the length > 5, otherwise it gets another func. I want to avoid using if/else as this is an exercise in coming out of that habit.</p>

<p>I could use ?: but this is only for two conditions. The main thing is this is for an API and I want the user of the API to just pass in the string as a parameter, and then look at the length and get the right func from the dictionary.</p>

<p>How best should I go about this?
Thanks</p>
