editor - 使用 'Block Body' 时,Visual Studio 可以使用 'Generate Method' ,但还是更喜欢 'Expression Body' 吗? (VS2019)

标签 editor intellisense visual-studio-2019

I use 'Generate Method' a lot (when typing a missing method call, Visual Studio offers to generate it), but when the options are set to prefer an Expression Body, it generates an Expression Body like this:

private void Blah() => throw new NotImplementedException();

然后我必须将其转换为块体,因为大多数方法都不是一行。有什么方法可以让 Visual Studio 生成块体方法但仍然建议表达式体方法?

最佳答案

I then have to convert it to a block body because most methods aren't one line. Is there any way to get Visual Studio to generate block body methods but still suggest expression body methods?



解决方案

请更改此:
Tools --> Options --> Text Editor --> C# --> Code Style --> Expression Preferences -->

偏好 Use expression body for methods从不

enter image description here

希望能帮到你。

关于editor - 使用 'Block Body' 时,Visual Studio 可以使用 'Generate Method' ,但还是更喜欢 'Expression Body' 吗? (VS2019),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60547628/

相关文章:

editor - 如何在 Visual Studio Code 中复制一行或所选内容?

javascript - 在golang中获取Ace.js编辑器的值

asp.net - 在 web.config 中注册的 Visual Studio 2008 用户控件未注册智能感知

c++ - Visual Studio 2017 中的 Intellisense 可以建议包含 C++ header 吗?

sql - Visual Studio 2019 架构比较未检测到差异

wpf - VS2019更新18.2缺少 "WPF App .NET Core"项目模板

javascript - 插入点位置上的 RichText 编辑器按钮状态

macos - 如何让 textmate 与 NFS 配合使用?

javascript - VS 代码中 Firebase 的代码完成?

visual-studio-2019 - Beyond Compare 4 和 Visual Studio 2019