Get assistance in migrating to new CSharp features

Skip to end of metadata
Go to start of metadata

As new versions of C# come out, it’s only natural to want to update your code to take advantage of the latest syntactic features. Luckily, ReSharper is there to help you update your code automatically.

First thing to note is the availability of context actions that help you make use of the latest features. For example, you can take a loop and convert it to LINQ just by invoking a corresponding context action. Given this code:

ReSharper will underline the foreach and offer a chance to convert it to a LINQ expression:

After the refactoring, we get the following code:

Of course, these hints are also mirrored in inspections:

Additionally, some of the language-related updates can be invoked via Code Cleanup. The exact changes (e.g., the option to change explicit type names to var) can be configured in ReSharper’s Options dialog under Code Cleanup:

  • No labels