Remove if

Hi,

is it possible to remove an if-surround.

Example:

I have following if block:


if(a == b)
{
  DoSomething();

}

Now I want to remove the if-surround by remaining the inner block by a magic shortcut. So the result should be:

DoSometing();


Is this possible by a standard feature or by a kind of template.



Markus

2 comments
Comment actions Permalink

Hi,

You could try to use Search and Replace with pattern. R# -> Tools -> Pattern Catalog. Let me know if it helps you.

--
Kirill Falk
.NET Team QA Lead
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Ok, I tried following replace pattern:

if surrounding.JPG

... and it works!


Example:

This:

      if (wizard != null && filePath.Length > 1)
      {
        //aa
        Console.WriteLine("test");
        Console.WriteLine("test2");
      }

becomes to:

      Console.WriteLine("test");
      Console.WriteLine("test2");

Oh my comment (//aa) is removed. So my pattern is not yet perfect...



Markus



0

Please sign in to leave a comment.