V
V
vladimirchelyabinskiy2016-05-19 09:43:44
C++ / C#
vladimirchelyabinskiy, 2016-05-19 09:43:44

C# how to compare two Lists?

There is a list1
Format: hash (32 characters) = File name
Example 8c75d84d6650219ec65f664b5cd8221b = DbRef.dll
There is a list2
Format: hash (32 characters)
Example 5139da6f02b10595c44460496a50552a It is
necessary to compare hashes and if they match, execute
Console.Write(Display file name);
Preferably a ready-made example, many thanks in advance !!! :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Антон Федорян, 2016-05-19
@vladimirchelyabinskiy

foreach (var item in list1.Where(item => list2.Contains(item.Substring(0, 32))))
{
   // Console.WriteLine(item);
}

Идем циклом по первому списку, находимым совпадения циклом по второму. Два цикла, один вложенный.
Это в лоб. Еще можно создать из одного списка словарь, поиск возможно будет быстрее и т.д.

Алексей, 2016-05-19
@k1lex

Сравниваете два листа используя LINQ JOIN и выводите результат

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question