How to convert a hashtable to a string in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections

Module HashTableToString
    Sub Main()
        Dim ht As New Hashtable()

        ht.Add("A", "C")
        ht.Add("B", "Java")
        ht.Add("C", "Python")
        ht.Add("D", "Go")
        ht.Add("E", "Rust")
        ht.Add("F", "TypeScript")

        Dim s As String = ""
        Dim enumerator As IDictionaryEnumerator = ht.GetEnumerator()

        While enumerator.MoveNext()
            s &= enumerator.Key.ToString() & " "
            s &= enumerator.Value.ToString() & ", "
        End While

        Console.WriteLine("String value: {0}", s)
    End Sub
End Module


	
' run:
'
' String value: A C, C Python, F TypeScript, E Rust, D Go, B Java, 
' 

 



answered Dec 4, 2025 by avibootz
...