String StartsWith() Any Way To Avoid 2 Checks?
<p>I have this code.  It wasn't obvious at the time, but the code as written is always going to pick the first option since both "fc" and "fcip" start with "fc".  </p>

<pre><code>string fcportdelimit = "fc";
string fcipportdelimit = "fcip";

if (BlockToProcess[0].StartsWith(fcportdelimit)) 
{
    try
    {
        this.ParseFCInterface(BlockToProcess);
    }
    catch (Exception E)
    {
        throw;
    } 
}
else if (BlockToProcess[0].StartsWith(fcipportdelimit)) 
{
    try
    {
        this.ParseFCIPInterface(BlockToProcess);
    }
    catch (Exception E)
    {
        throw;
    } 
}
</code></pre>

<p>I looked through the string class but don't see a StartsWith() or Contains() that takes a pattern as input.   The string I am testing against is either going to be a patttern fcN/N or fcipN where N is a number. So, I am thinking I would have to do something like this?</p>

<pre><code>if (BlockToProcess[0].StartsWith(fcportdelimit || fcipportdelimit) 
{ 
    if (BlockToProcess[0].StartsWith(fcipportdelimit)
    { 
       // do something here
    } 
    else
    { 
       //since fcipportdelimit didn't match it must be an fcport
       //so do something else
    }
}
</code></pre>
