Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReSharper suggests the usage of var - Can it do the opposite thing aswell?

Tags:

c#

resharper

Resharper does suggest me the usage of the var-keyword. Unfortunately, my new employer does not use var-keyword at all. Thats why I am having some trouble, because I am used to use the var-keyword.

Is it possible to let resharper do the opposite thing? So, it warns me everytime I use the var keyword and suggests me to declare the variable explicitly?

Thanks in advance!

Edit:\

I dont want to turn off the warning or something like that, I want to turn that Setting around, so I will get a warning whenever I'm using var.

like image 438
Jannik Avatar asked Nov 30 '22 17:11

Jannik


2 Answers

From the toolbar at the top click Resharper - Options - Code Editing - C# - Code Style you will find 'var usage declarations' you then need to set the preference to 'Use explicit type' for 'Built in types', 'Simple Types' & 'Elsewhere'.

ReSharper options dialog - var usage

like image 198
Tom Biddulph Avatar answered Dec 05 '22 06:12

Tom Biddulph


Go to Resharper Options, then to Code Editing->C#->Code Style.

There you can set everything like you want it.

Select your needed Preference or the notification level.

like image 20
GreenEyedAndy Avatar answered Dec 05 '22 06:12

GreenEyedAndy