using System;
using System.Collections.Generic;

namespace Practica03Tema2
{
    class Program
    {
        static void Main(string[] args)
        {
            // HashSet ciudades
            HashSet<string> ciudades = new HashSet<string>();
            ciudades.Add("Tokio");
            ciudades.Add("CDMX");
            ciudades.Add("London");
            ciudades.Add("Paris");
            ciudades.Add("CDMX");
            ciudades.Add("CDMX");
            ciudades.Add("Monaco");
            ciudades.Add("Nueva York");
            ciudades.Add("Madrid");
            ciudades.Add("Roma");
            ciudades.Add("Nueva York");

            Console.WriteLine($"Numero de ciudades: {ciudades.Count}");

            // HashSet clientes
            HashSet<int> clientes = new HashSet<int>();
            clientes.Add(1001);
            clientes.Add(1005);
            clientes.Add(1001);
            clientes.Add(1008);
            clientes.Add(1005);
            clientes.Add(1010);
            clientes.Add(1001);
            clientes.Add(1008);

            Console.WriteLine($"Clientes unicos: {clientes.Count}");

            // Detectar duplicados
            int[] ids = { 1001, 1002, 1003, 1003, 1004, 1005, 1001 };

            HashSet<int> vistos = new HashSet<int>();
            foreach (int id in ids)
            {
                if (!vistos.Add(id))
                {
                    Console.WriteLine($"Cliente con mas de una compra: {id}");
                }
            }
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: