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

白昼怎懂夜的黑 提交于 2019-12-23 13:26:10

问题


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.


回答1:


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'.




回答2:


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.




回答3:


You can set the inspection severity in Resharper-Options-Code Inspection-Inspection Severity-C# and search for var

And you can set if var is prefered or not as well:



来源:https://stackoverflow.com/questions/32630460/resharper-suggests-the-usage-of-var-can-it-do-the-opposite-thing-aswell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!