是否可以在VS.NET 2010中的数组初始值设定项中启用C#源代码格式化?数组初始值设定项中的C#源代码格式化
Elements =
{
// starting from here source code formatting does not work
new TextViewModel("PublicId")
{
Label = new LText("Fund Nr:", "de", "Fondsnummer"),
Watermark = new LText("Please enter fund number...", "de", "Bitte hier Fondsnummer erfassen...")
},
new CheckViewModel("Juristic")
{
Style = "Radio",
Default = true,
Label = new LText("Juristic Fund", "de", "Juristischer Fonds")
}
}
// starting from here source code formatting works again
我是否在工具 - >选项 - >文本编辑器 - > C#中缺少一些格式选项?
从你对我的回答的评论:“代码片段取自对象初始值设定项。” - 有什么机会可以添加更多的上下文?我用`var foo = new Foo {Elements = ...}`试过了,它是有效的C#。它只是看起来不像你的片段。 – 2011-01-08 15:46:58
直到vs2013,对于数组和列表初始化程序,问题仍然存在 – 2015-04-15 12:51:40