Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
2
Indexable
Never
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string filePath = @"C:\example.txt"; // замените на путь к вашему файлу
        List<string> lines = ReadLinesFromFile(filePath);

        List<string> uniqueLines = GetUniqueLines(lines);

        Console.WriteLine("Уникальные строки:");
        foreach (string line in uniqueLines)
        {
            Console.WriteLine(line);
        }
    }

    static List<string> ReadLinesFromFile(string filePath)
    {
        List<string> lines = new List<string>();
        using (StreamReader reader = new StreamReader(filePath))
        {
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                lines.Add(line);
            }
        }
        return lines;
    }

    static List<string> GetUniqueLines(List<string> lines)
    {
        return lines
            .Where(line => line.Distinct().Count() == line.Length)
            .ToList();
    }
}