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
至 从不 希望能帮到你。
关于editor - 使用 'Block Body' 时,Visual Studio 可以使用 'Generate Method' ,但还是更喜欢 'Expression Body' 吗? (VS2019),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60547628/