Search code examples
c#vb.netcode-conversion

Convert this C# dictionary to VB.NET


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"}}
};

Solution

  • Private Shared ReadOnly ValidHtmlTags As Dictionary(Of String, List(Of String)) = New Dictionary(Of String, List(Of String))
    

    Then somewhere in a Sub or a Function:

    ValidHtmlTags.Add("param", New List(Of String))
    ValidHtmlTags("param").Add("name")
    ValidHtmlTags("param").Add("value")
    
    ValidHtmlTags.Add("object", New List(Of String))
    ValidHtmlTags("object").Add("id")
    ValidHtmlTags("object").Add("type")
    
    ValidHtmlTags.Add("embed", New List(Of String))
    ValidHtmlTags("embed").Add("src")
    ValidHtmlTags("embed").Add("type")
    ValidHtmlTags("embed").Add("wmode")