Visual Studio代码中的C#语言模式将是代码底部的大括号{},我想在前面打开它,类似于我已经习惯的在JavaScript中的模式,下面我留下了一个C#模式的示例
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Hello World");
}
}
}
Visual Studio代码中的C#语言模式将是代码底部的大括号{},我想在前面打开它,类似于我已经习惯的在JavaScript中的模式,下面我留下了一个C#模式的示例
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Hello World");
}
}
}
try 在项目根目录下添加.editorconfig文件,并将csharp_new_line_before_open_brace
设置为none
:
[*.cs]
csharp_new_line_before_open_brace = none
但请注意,C#项目的默认样式是在新行上放置大括号,大多数AFAIK(但不是所有)都使用这种样式.请参阅Common C# code conventions: Style guidelines个文档:
对花括号使用"Allman"样式:左花括号和闭花括号有自己的新行.大括号与当前缩进级别对齐.
另见: