using System.Collections.Generic;
public static void Main()
var customers = new List<Customer>()
new Customer() { Id = 1, Name = "Abel", Age = 41, City = "Madrid" },
new Customer() { Id = 2, Name = "Andres", Age = 22, City = "London" },
new Customer() { Id = 3, Name = "Alice", Age = 38, City = "Lisbon" },
new Customer() { Id = 4, Name = "Ana", Age = 61, City = "Berlin" },
new Customer() { Id = 1, Name = "Billy", Age = 35, City = "Rome" },
new Customer() { Id = 1, Name = "Lock", Age = 25, City = "Rome" },
var policies = new List<Policy>()
new Policy() { Id = 50, Customer = 1, Premium = 120.0, City = "Madrid" },
new Policy() { Id = 500, Customer = 2, Premium = 20.0, City = "London" },
new Policy() { Id = 5000, Customer = 3, Premium = 100.0, City = "Lisbon" },
new Policy() { Id = 50000, Customer = 1, Premium = 10.0, City = "Madrid" },
new Policy() { Id = 40000, Customer = 5, Premium = 1200.0, City = "Athenas" },
new Policy() { Id = 80000, Customer = 1, Premium = 1000.0, City = "Madrid" },
var dictionary = new Dictionary<string, List<int>>();
int countCustomers = customers.Count;
for(int i = 0; i < countCustomers; i++)
List<int> records = null;
string key = string.Concat(item.Id.ToString(), item.City);
if(!dictionary.TryGetValue(key, out records))
records = new List<int>();
dictionary[key] = records;
foreach (var item in dictionary)
Console.WriteLine(item.Key + "\t\t" + string.Join(", ", item.Value));