using System.Collections.Generic;
public static void Main()
int[] numbers = new int[] { 1, 7, 9, 7, 4, 5, 8, 5, 4, 1, 9 };
int? singleOccurrence = null;
var alreadyCounted = new HashSet<int>();
foreach(var item in numbers)
if (alreadyCounted.Add(item))
Console.WriteLine($"Item that only appeared once is: {singleOccurrence}");
Console.WriteLine($"Number of items in the original collection: {numbers.Length}");
Console.WriteLine($"Number of items in the dictionary: {alreadyCounted.Count}");