Assuming the same order and length of dictionaries, you can use Zip to stitch the two dictionaries together:
Sub Main
Dim sb = New StringBuilder()
Dim DicMonth = New Dictionary(Of String, Integer)() From { _
{"Jan", 674}, _
{"Feb", 635} _
}
Dim DicMeetTotal = New Dictionary(Of String, Integer)() From { _
{"Jan", 670}, _
{"Feb", 631} _
}
Dim lineStrings = DicMonth.Zip(DicMeetTotal, _
Function(m, mt) String.Format("{0} {1} Meet {2} Missed {3}", _
m.Key, m.Value, mt.Value, m.Value - mt.Value))
For Each ls In lineStrings
sb.AppendLine(ls)
Next
Console.WriteLine(sb.ToString())
End Sub
Alternatively, if there is a join key (e.g. the Key value in both dictionaries is the same), you can use Linq Join them together, like so:
Dim lineStrings = DicMonth.Join(DicMeetTotal, _
Function(m) m.Key, Function(mt) mt.Key, _
Function(m, mt) String.Format("{0} {1} Meet {2} Missed {3}", _
m.Key, m.Value, mt.Value, m.Value - mt.Value))
Edit
Assuming that you wouldn't have modelled N different dictionaries each containing just a single value (this would be a modelling error along the lines of Entity Attribute Value, IMO), I'm guessing you'll want an entity to hold the data:
Class MeetTotalEntity
Public Property Meet As Integer
Public Property Missed As Integer
Public Property Cancel As Integer
Public Property Other As Integer
End Class
And then the Zip (or Join) still holds. The Value
of the second dictionary contains the above entity, so just dereference the fields accordingly.
Sub Main
Dim sb = New StringBuilder()
Dim DicMonth = New Dictionary(Of String, Integer)() From { _
{"Jan", 674}, _
{"Feb", 635} _
}
Dim DicMeetTotal = New Dictionary(Of String, MeetTotalEntity)() From { _
{"Jan", New MeetTotalEntity With {.Meet = 670, .Missed = 4, .Cancel = 10, .Other = 5}}, _
{"Feb", New MeetTotalEntity With {.Meet = 631, .Missed = 10, .Cancel = 3, .Other = 2}} _
}
Dim lineStrings = DicMonth.Zip(DicMeetTotal, _
Function(m, mt) String.Format("{0} Total {1} Meet {2} Missed {3} Cancel {4} Other {5}", _
m.Key, m.Value, mt.Value.Meet, mt.Value.Missed, mt.Value.Cancel, mt.Value.Other))
For Each ls In lineStrings
sb.AppendLine(ls)
Next
Console.WriteLine(sb.ToString())
End Sub