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

如何让Visual Studio将switch多case结果放在同一行?

阻止Visual Studio自动拆分switch语句的case标签

要让Visual Studio停止将switch语句中连续的case标签拆分为单独行,只需调整以下设置:

  1. 打开Visual Studio的选项窗口:
    • 点击顶部菜单栏的 Tools > Options(或按快捷键 Alt+T 后按 O)。
  2. 在左侧导航栏依次展开:
    Text Editor > C# > Code Style > Formatting > Wrapping。
  3. 在右侧找到 Wrap case labels 选项:
    • 将默认的 Wrap each case label on a new line 改为 Do not wrap case labels。
  4. 点击 OK 保存设置。

修改完成后,当你使用快捷键 Ctrl+K, Ctrl+F 自动格式化代码时,原本写在同一行的多个case标签(如 case 0: case 1:)将保持在同一行,不会被拆分为单独的行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 12:34:53