Resharper可以将var更改为显式类型吗?

Fat*_*ert 8 resharper

是否有可能使Resharper的工具"清理代码"(在Visual Studio中)将所有var内容更改为显式类型?

示例:我喜欢这个:

var person = new Person();
Run Code Online (Sandbox Code Playgroud)

改为:

Person person = new Person();
Run Code Online (Sandbox Code Playgroud)

建议解决方案后编辑:

也许我做错了什么,但它对我不起作用:

图像显示建议的解决方案不起作用

Axe*_*zek 9

您可以在Code Cleanup下的(Resharper)选项中进行设置.只需创建一个新的配置文件/修改现有配置文件,然后导航到C# - >在声明中使用'var'.将"Replace direction"设置为"Can(change)'var'到type usage"和"Local variable declaration style"到"Always use explicit type"


Sjo*_*erd 2

是的。在“代码清理”工具中,在“在声明中使用‘var’”下,将“替换方向”设置为“可以‘var’来键入用法”。

创建自定义配置文件