Easy csharp

HashSet — remove duplicates #63

Problem

Store unique numbers in HashSet.

Hints
  • new HashSet<int>

Your practice code

Ready — edit the code above and click Run.

Solution

using System;

class Program
{
    static void Main()
    {
        using System.Collections.Generic;
        var set = new HashSet<int> { 1, 2, 2, 3 };
        Console.WriteLine(set.Count);
    }
}

Try solving on your own first, then reveal the official answer.

Explanation

HashSet enforces uniqueness automatically.

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details