c# - 如何在 Visual Studio 中使用 "Light bulb"重构工具来使用显式类型而不是 var?

标签 c# visual-studio-2015 refactoring

当我使用 Visual Studio 中内置的灯泡重构来生成局部变量时,它始终使用 var 语法:

enter image description here enter image description here

我(个人)不喜欢 var 并且更喜欢它使用显式类型(在本例中为 double)。所以它应该创建代码:

double v = CalculateDownTime(lineid, start, end);

如何更改 Visual Studio 设置才能执行此操作?可能吗?

请不要讨论 var 与显式类型的优缺点。不,我不想使用 Resharper。

最佳答案

我刚刚找到了,这个related question helped

取消勾选生成本地变量时使用var:

enter image description here

关于c# - 如何在 Visual Studio 中使用 "Light bulb"重构工具来使用显式类型而不是 var?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42553609/

相关文章:

c# - 为什么 "propdp"代码片段不使用 nameof 运算符作为注册属性的名称?

c++ - 重构指向某种形式模板的函数指针

java - 以编程方式重构参数名称

c# - .ToBitmap : Missing 'Using Directive' or 'Assembly Reference'

c - 表达式必须有算术类型

c - C中查询字符串的优雅解析

c# - 无法将默认比较器作为 IComparer<object>

c# - 将 null 作为构造函数/方法参数传递时出现编译错误 - c#

c# - 如何使用 Entity Framework 执行插入查询

c# - 使用 Windows 10 IOT Core 在 Raspberry Pi 中播放 wav 文件