Imports System
Imports System.Collections.Generic
Public Class Program
Public Shared Sub Main()
Dim s As String = "c# programming language"
Dim dict As Dictionary(Of Char, Integer) = New Dictionary(Of Char, Integer)()
For Each ch As Char In s.Replace(" ", String.Empty)
If dict.ContainsKey(ch) Then
dict(ch) = dict(ch) + 1
Else
dict.Add(ch, 1)
End If
Next
For Each item In dict.Keys
Console.WriteLine(item & " : " & dict(item))
Next
End Sub
End Class
' run:
'
' c : 1
' # : 1
' p : 1
' r : 2
' o : 1
' g : 4
' a : 3
' m : 2
' i : 1
' n : 2
' l : 1
' u : 1
' e : 1
'