ReSharper 2024.3.5 for VS 2022 - C# why var replacement?

已回答

I don't understand why ReSharper C# wants to replace every explicit type with “var” (infer the type)?  This surely could introduce more bugs not less?

Also, there is no “ReSharper” Topic category in this forum?

0

Hello Robin,

Please note that there's an option that opens an article describing why ReSharper is suggestion any certain quick-fix:

For using var there's an article - Code inspection: Use preferred 'var' style (for built-in types) | ReSharper Documentation.

It's also worth mentioning that this behavior could be easily configured in ReSharper | Options | Code Editing | C# | Syntax Style | ‘var’ usage in declarations.

You can ask all ReSharper relevant questions on ReSharper forum.

0

Thanks for the information, good to know it can be disabled.  

Other than “it's popular” and claim of "easier to read", there doesn't appear to be any technical reason to default to Var.  Not sure I agree with the “easier to read”. 

FYI, would be handy to see a SQL to LINQ conversion in ReSharper.  I do a lot of legacy conversions from Stored Procedures to EF Core/LINQ.

On another side note, ReSharper is getting better and better with each release, especially the AI aspect.

Thanks for the response, Rob.

0

请先登录再写评论。