title: How to use Dictionary in VB.net?
body: <p>I have written this function to auto correct gender to M or F from different values in a string array. It works fine but my manager told me to use Dictionary which he said is more efficient. But I have no idea. Anyone like to help me to understand how this can be done ? Thanks.</p>
  
  <pre><code>    Public Function AutoGender(ByVal dt As DataTable) As DataTable        
  
      Dim Gender As String = ""
      Dim Mkeywords() As String = {"boy", "boys", "male", "man", "m", "men", "guy"}
      Dim Fkeywords() As String = {"girl", "girls", "female", "woman", "f", "women", "chick"}
      Dim row As DataRow
          For Each row In dt.Rows
              If Mkeywords.Contains(row("Gender").ToString.ToLower) Then
                  Gender = "M"
                  row("Gender") = Gender
              ElseIf Fkeywords.Contains(row("Gender").ToString.ToLower) Then
                  Gender = "F"
                  row("Gender") = Gender
              End If
          Next
      Return dt
  
      End Function
  </code></pre>