using System.Collections;
using System.Collections.Generic;
public static void Main()
List<KeyValuePair<string, int>> EmployeeDept = new List<KeyValuePair<string, int>> {
new KeyValuePair<string, int> ("Gates",2),
new KeyValuePair<string, int> ("Nadella",2),
new KeyValuePair<string, int> ("Mark",3),
new KeyValuePair<string, int> ("Pichai",4)
int[] deptToFilter ={3,4};
Console.WriteLine ("Approach 1 - Using Contains");
Console.WriteLine ("==========================================");
var filterdByContains = EmployeeDept.Where(emp => deptToFilter.Contains(emp.Value));
foreach (var dept3and4employees in filterdByContains)
Console.WriteLine(dept3and4employees.Key+" - "+dept3and4employees.Value);
Console.WriteLine ("\n\nApproach 2 - Using Join");
Console.WriteLine ("==========================================");
var filteredByJoin = EmployeeDept.Join(
empdept => empdept.Value,
filterdept => filterdept,
(empdep,filddep) => new KeyValuePair<string, int>(empdep.Key, empdep.Value)
foreach (var dept3and4employees in filteredByJoin)
Console.WriteLine(dept3and4employees.Key+" - "+dept3and4employees.Value);