我在VB.NET中有一个多行语句,我想在行之间添加注释以帮助澄清一些内容。
基本上,我希望评论看起来像这样:
New PropertyThingy() From {
{"reallyLongDictionaryKeyNameThatIsExcessivelyLong", data.reallyLongPropertyName},
{"theApiMaintainerReallyLikesVerboseKeys", data.Blagh},
' I'd like to put a line here...
{"whyAreTheseReallyVerbose", data.SomeProperty},
}
不幸的是,由于这个错误,我无法编译它:"语法错误:期望收集元素初始化程序。"有没有办法在线之间得到评论?
我也试过这个:
New PropertyThingy() From {
{"reallyLongDictionaryKeyNameThatIsExcessivelyLong", data.reallyLongPropertyName},
{"theApiMaintainerReallyLikesVerboseKeys", data.Blagh},
_ ' Some comment goes here:
{"whyAreTheseReallyVerbose", data.SomeProperty},
}
答案 0 :(得分:3)
这似乎是初始化Dictionary的代码。那么你不需要下划线,但你仍然不能在这些行之间做出评论。
但是你可以在同一行写下评论
Dim c = New Dictionary(Of String, Integer)() From
{
{"abc", 1}, ' Description of the first entry
{"def", 2} ' Description of the second entry
}