How to print only the keys from a dictionary in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic
                 
Public Module Module1
	Public Sub printOnceKey(arr() As Integer) 
		Dim dict As Dictionary(Of Integer, Integer) = New Dictionary(Of Integer, Integer)
		
		For i As Integer = 0 To arr.Length - 1
			dict.Add(arr(i), i) 
		Next
		
		Dim keys As Object   = dict.Keys
		For Each n As Integer In keys
    		Console.Write("{0, 3}", n)
		Next
	End Sub
    Public Sub Main()
        Dim arr() As Integer = {12, 11, 18, 19, 30}
  
        printOnceKey(arr)
    End Sub
End Module
     
     
     
' run:
'
'   12 11 18 19 30
'
	

 



answered May 4, 2020 by avibootz
...