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: 
`as` is arguably better *if* the resulting expression is used later on; `is` is just as good if not. E.g.

```
if (sender is Button) {
    Button button = (Button)sender;  // just use `as`, as suggested
    button.Push();

```

(I thought ReSharper only gave a warning/hint in the case *where* a duplicate cast could be eliminated, such as this..)

That being said, I use the structure

```
Button button;
if ((button = sender as Button) != null) {
    button.Push();

```

to ensure that the variable is initialized in (and only starting in) the condition - this defers the application of `as` to the appropriate conditional expression and allows C#/ReSharper to detect some incorrect [uninitialized] variable usage cases.

---

See also:

[Casting vs using the 'as' keyword in the CLR](https://stackoverflow.com/questions/496096/casting-vs-using-the-as-keyword-in-the-clr) - Jon's answer has 'is/(cast)' pairings as a "don't do" raising concerns with both shared and field vs. property access. Performance and 'is' vs 'as' differences are also discussed.

And a duplicate [Which code is better: using "as" or "is"?](https://stackoverflow.com/questions/12204132/which-code-is-better-using-as-or-is?lq=1), with some better related links.
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.