C#: iterate ( loop ) through Dictionary

Trabla: C#: iterate ( loop ) through Dictionary<string,string>

Solving:

// Keys and Values

foreach( var lvItem in lvDictionary ){

      System.Diagnostics.Debug.WriteLine(   lvItem.Key );
      System.Diagnostics.Debug.WriteLine(   lvItem.Value);
}


// Iterate only throw collection of Keys

foreach( var lvItemKey in lvDictionary.Keys ){

      System.Diagnostics.Debug.WriteLine(   lvItemKey );

}

 // Iterate only throw collection of Values

foreach( var lvItemValue in lvDictionary.Values ){

      System.Diagnostics.Debug.WriteLine(  lvItemValue );
    
}


No comments:

Post a Comment