Tool to refactor C# var to explicit type

前端 未结 7 651
陌清茗
陌清茗 2020-12-03 17:15

Our coding standards ask that we minimise the use of C# var (suggests limiting it\'s use to being in conjunction with Linq). However there are times when using generics wher

7条回答
  •  爱一瞬间的悲伤
    2020-12-03 17:43

    This is possible in Visual Studio 2017.

    Tools > Options > Text Editor > C# > Code Style > General –

    Find 'var' preferences > When variable type is apparent. For Preference select "Prefer explicit type," and for Severity select "Suggestion."

    You'll now get the light bulb actions when you use var, and you can quickly change to the explicit type by using the Ctrl. shortcut key.

提交回复
热议问题