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.
tip
By default, ReSharper automatically detects C# version based on the associated compiler. However, you can specify the target C# version explicitly for a project — right-click the project in the Solution Explorer, choose Edit project item properties from the context menu and use the C# Language Level selector .
To set the C# version for all projects in your solution, specify it in a Directory.Build.props file in your solution directory as described here.
Let's take as an example one of the C# 6.0's best loved features - conditional access expressions. First thing to note is that ReSharper gently points at possibilities to use new language features right in the editor:
As usual, pressing AltEnter on the highlighted code brings up a quick-fix that helps you make use of the new language feature:
After applying the fix, the method is transformed as follows:
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions. Learn more.
With your consent, JetBrains may also use cookies and your IP address to collect individual statistics and provide you with personalized offers and ads subject to the Privacy Notice and the Terms of Use. JetBrains may use third-party services for this purpose. You can adjust or withdraw your consent at any time by visiting the Opt-Out page.