Use of `is` and `as` in multiple conditions
<p>Quite recently, I thought about the use of <code>as</code>, <code>is</code> and direct cast in C#. </p>

<p>Logically, is it a better idea to use :</p>

<pre><code> var castedValue = value as type;
 if (null != castedValue)
 {
     // Use castedValue.
 }
</code></pre>

<p>than :</p>

<pre><code>if (value is type)
{
    var castedValue = (type)value;
    // Use castedValue.
}
</code></pre>

<p>But I still have issues when dealing with this kind of pattern:</p>

<pre><code>if (value is Implementation1)
{
    var castedValue = (Implementation1)value;
    // Use castedValue in a first way.
}
else if (value is Implementation2)
{
    var castedValue = (Implementation2)value;
    // Use castedValue in a second way.
}
else if (value is Implementation3)
{
    var castedValue = (Implementation3)value;
    // Use castedValue in a thrid way.
}
// And so on...
</code></pre>

<p>How can I improve this code to prevent casting two times when OK, and is it really necessary to cast twice? </p>

<p>I don't want to make the code unreadable, but the idea is not to test a cast if a previous one succeeded.</p>

<p>I had several ideas to fix this, but none of them seems to really satisfy the conditions...</p>

<p><strong>Edit:</strong></p>

<p>Here is a case I've got... There is this object that is created by a lower part of teh code I do not have control on. This object can be of several inherited types. In my layer, I do want to create a specific object depending on this type. I do have this constructor class:</p>

<pre><code>public static IHighLevelObject MakeHighLevelObject(LowLevelObject lowLevelObject)
{
    IHighLevelObject highLevelObject;

    if (lowLevelObject is LowLevelObject1)
    {
        highLevelObject = new HighLevelObject1((LowLevelObject1)lowLevelObject);
    }
    else if (lowLevelObject is LowLevelObject2)
    {
        highLevelObject = new HighLevelObject2((LowLevelObject2)lowLevelObject);
    }
    else if (lowLevelObject is LowLevelObject3)
    {
        highLevelObject = new HighLevelObject3((LowLevelObject3)lowLevelObject);
    }
    // And so on...

    return highLevelObject;
}
</code></pre>

<p>How do I solve this case ?</p>
