visual-studio Visual Studio switch 语句格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/612516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:14:45  来源:igfitidea点击:

Visual Studio switch statement formatting

visual-studio

提问by Michael Warner

I'm using Visual Studio 2005. It always wants to format switch statements like this:

我正在使用 Visual Studio 2005。它总是想像这样设置 switch 语句的格式:

switch (thing)
{
case A:
  stuff;
  break;

case B:
  things;
  break;
}

Is there a way to have it indent the cases like this?:

有没有办法让它缩进这样的案例?:

switch (thing)
{
  case A:
    stuff;
    break;

  case B:
    things;
    break;
}

回答by Andrew Hare

Go here:

到这里:

Tools > Options > Text Editor > C# > Formatting > Indentation > Indent case labels

Tools > Options > Text Editor > C# > Formatting > Indentation > Indent case labels

回答by Mez

Tools | Options | Text Editor | c# -> check 'Ident block contents' checkbox.

工具 | 选项 | 文本编辑器 | c# -> 选中“标识块内容”复选框。