Question: I have this algorithm

```
int oglinda(int n)
{
    if(n>9)
    {

        cout << n%10;
        oglinda(n/10);
    }
}

```

and it returns a number from right to left for example for 341=>143.
Here's the problem:
When the algorithm reaches the last number (which is < 9) it shouldn't receive it's value but instead it does. How comes that when the number is less than 9?

Answer: 
The "as" operator is used to perform conversions between compatible types. Whereas the "is" operator is used to check whether the run-time type of an object is compatible with a given type or not.

So I think as would be a better option to go with as the as operator attempts to cast an object to a specific type, and returns null if it fails.

You can also check **Eric Liperts** blog on **[Is is as or is as is?](http://blogs.msdn.com/b/ericlippert/archive/2010/09/16/is-is-as-or-is-as-is.aspx)**

> 
> However, in practice the CLR provides us instruction isinst, which
>  ironically acts like as. Therefore we have an instruction which
>  implements the semantics of as pretty well, from which we can build an
>  implementation of is. In short, de jure is is is, and as is as is is,
>  but de facto is is as and as is isinst.
> 
> 
> 

And **[What's the difference between "as" and "cast" operators?](http://blogs.msdn.com/b/ericlippert/archive/2009/10/08/what-s-the-difference-between-as-and-cast-operators.aspx)**

From [here](http://www.codeproject.com/Tips/532831/Use-of-Is-and-As-operators-in-Csharp):

> 
> **Advantage of 'as' over 'is**
> 
> 
> In the case of is operator, to type cast, we need to do two steps:
> 
> 
> 1. Check the Type using is
> 2. If it’s true then Type cast
> 
> 
> Actually this affects the performance since each and every time the
>  CLR will walk the inheritance hierarchy, checking each base type
>  against the specified type. **To avoid this, use as it will do it in one
>  step.** Only for checking the type should we use the is operator.
> 
> 
>
You did not post all your code. I guess in your code, if the sender is a button, you cast it to button and do something with it. If that's the case, you did that work *twice*, once in the if and once in the statement block. Resharper told you to do it once and be done with it.