You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何设置Resharper使C# switch的case子句内容同行显示?

解决Resharper自动拆分switch短case行的问题

你需要调整Resharper里的两个关键设置,步骤如下:

  1. 打开Resharper选项(快捷键Alt+R, O),依次导航到:
    Code Editing >> C# >> Formatting Style >> Line Breaks and Wrapping >> Statements >> Switch case statements

  2. 勾选以下两个选项:

    • Allow putting 'case' label and its statement on the same line
    • Allow putting 'break' on the same line as the last statement in 'case'
  3. 保存设置后,回到代码中重新格式化(快捷键Ctrl+Alt+F),短case的赋值语句和break就能保持在同一行了。

如果你的Resharper版本不同,选项名称可能略有差异,但核心是找到与switch case语句换行相关、允许将case标签、执行语句、break放在同一行的设置项。

内容的提问来源于stack exchange,提问作者Joe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 00:25:20