Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,845 questions

51,766 answers

573 users

How to create key value dictionary in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Public Class Program
	Public Shared Sub Main()
        Dim dict As Dictionary(Of String, Integer) = New Dictionary(Of String, Integer)()
		
        dict("csharp") = 1
        dict("c") = 4
        dict("java") = 6
        
		dict.Add("python", 9)
        
		Console.WriteLine("key values:")
        For Each kvp As KeyValuePair(Of String, Integer) In dict
            Console.WriteLine(kvp.Key & " - " & kvp.Value)
        Next

        Console.WriteLine(Environment.NewLine & "keys:")
        For Each key As String In dict.Keys
            Console.WriteLine(key)
        Next

        Console.WriteLine(Environment.NewLine & "values:")
        For Each val As Integer In dict.Values
            Console.WriteLine(val.ToString())
        Next
    End Sub
End Class





' run:
'
' key values:
' csharp - 1
' c - 4
' java - 6
' python - 9
' 
' keys:
' csharp
' c
' java
' python
' 
' values:
' 1
' 4
' 6
' 9
' 

 



answered Dec 10, 2022 by avibootz

Related questions

2 answers 151 views
1 answer 160 views
2 answers 122 views
1 answer 167 views
167 views asked Sep 26, 2018 by avibootz
1 answer 178 views
...