using System; using System.Collections.Generic; var photos = new[] { new Photo("Lake", "IMG_001.jpg", "c349"), new Photo("Lake", "IMG_002.jpg", "aaaa"), new Photo("Forest", "IMG_001.jpg", "9f1e"), new Photo("Backup", "copy_002.jpg", "aaaa"), new Photo("Forest", "IMG_007.jpg", "ffa1"), }; Console.WriteLine("Photo import preview"); Console.WriteLine("Keep the first file with each unique content fingerprint."); Console.WriteLine(); IReadOnlyList selected = SelectUniquePhotos(photos); PrintImportSummary(photos, selected); static IReadOnlyList SelectUniquePhotos(IReadOnlyList photos) { var seen = new HashSet(StringComparer.Ordinal); var selected = new List(); foreach (Photo photo in photos) { if (seen.Add(photo.FileName)) { selected.Add(photo); } } return selected; } static void PrintImportSummary( IReadOnlyList photos, IReadOnlyList selected) { Console.WriteLine($"Files scanned: {photos.Count}"); Console.WriteLine($"Files selected: {selected.Count}"); foreach (Photo photo in selected) { Console.WriteLine($" {photo.Album}/{photo.FileName} [{photo.ContentFingerprint}]"); } Console.WriteLine($"Files skipped: {photos.Count - selected.Count}"); } record Photo( string Album, string FileName, string ContentFingerprint); // Есть ли баги в этом коде?