79192255

Date: 2024-11-15 11:55:59
Score: 2
Natty:
Report link

You can get a list of the unique values using the constructor of HashSet

List<int> numbers = new() { 1, 2, 2, 2, 5, 6};
List<int> uniqueValues= new HashSet<int>(numbers).ToList();
int numberOfElements = uniqueValues.Count;

Credit to: https://josipmisko.com/posts/c-sharp-unique-list

Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Gideon