将此 C# 字典转换为 VB.NET
如何将以下 C# 代码转换为 VB.NET?
转换工具做得不太好。
private static readonly Dictionary<string, List<string>> ValidHtmlTags = new Dictionary<string, List<string>> {
{ "param", new List<string>() {"name","value"}},
{ "object", new List<string>() {"id","type"}},
{ "embed", new List<string>() {"src","type","wmode"}}
};
How do I convert the following C# code to VB.NET?
The conversion tool is not doing a good job.
private static readonly Dictionary<string, List<string>> ValidHtmlTags = new Dictionary<string, List<string>> {
{ "param", new List<string>() {"name","value"}},
{ "object", new List<string>() {"id","type"}},
{ "embed", new List<string>() {"src","type","wmode"}}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我相信答案是VB.NET 3.5不支持集合初始化语法。
.NET 4 中的 VB.NET 支持集合初始值设定项 如下:
前面的代码示例与下面的代码等效。
I believe the answer is that VB.NET 3.5 does not support collection initialization syntax.
VB.NET in .NET 4 does support collection initializers as follows:
The previous code example is equivalent to the following code.
你想要这样的东西(对于.NET 3.5):
You want something like this (for .NET 3.5):
然后在 Sub 或 Function 中的某处:
Then somewhere in a Sub or a Function:
有一些不错的 C# <--> VB.NET 也可以在线转换。我使用 http://www.developerfusion.com/tools/convert/csharp -to-vb/ 获取:
然后构建每个 List(Of String) 并分别添加到 ValidHtmlTags。例如。
我不确定您是否可以将值列表传递到 VB.NET 中的 List(Of String) 构造函数中。
There are a few decent C# <--> VB.NET converts online as well. I use http://www.developerfusion.com/tools/convert/csharp-to-vb/ to get:
Then build each List(Of String) and add to ValidHtmlTags separately. eg.
I'm not sure you can pass in a list of values into the List(Of String) constructor in VB.NET.