using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
var myDictionary = new Dictionary<int, string>
{
{ 1, "C#" },
{ 2, "C" },
{ 3, "C++" },
{ 4, "Java" },
{ 5, "Python" }
};
// Filter: Keep only entries where the key is greater than 2
var filteredDictionary = myDictionary
.Where(kv => kv.Key > 2)
.ToDictionary(kv => kv.Key, kv => kv.Value);
foreach (var kv in filteredDictionary) {
Console.WriteLine($"Key: {kv.Key}, Value: {kv.Value}");
}
}
}
/*
run:
Key: 3, Value: C++
Key: 4, Value: Java
Key: 5, Value: Python
*/