K_McCormic
K_McCormic

Reputation: 334

ContainsValue VB

I have a dictionary set up with the entries. I wanted to get the letter that corresponds to the value and I am a bit stuck on the coding side of it. Here is my code so far:

Dim chardict As New Dictionary(Of Char, Integer)
chardict.Add("A", 0)
chardict.Add("B", 1)

If chardict.ContainsValue(1) then
   Console.WriteLine(the letter that corrosponds to the value)
end if

Output: B

Thanks in advance

Upvotes: 1

Views: 342

Answers (1)

Darren
Darren

Reputation: 70718

Add this into your IF statement:

 Dim Value = (From t In chardict
          Where t.Value = 1
          Select t.Key
          )

  Console.WriteLine(Value(0))

Upvotes: 2

Related Questions