Alan72104
Alan72104
CC#
Created by Alan72104 on 2/22/2023 in #help
❔ LINQ distinct from 2 lists preserving order as soon as they are seen
I have 2 lists like this 1: {1, 2, 3} 2: {1, 3, 4} what's the LINQ distinct method for them that provides this output? {1, 2, 3, 4} it should be the functional equivalent as this, and not ordering by value
List<string> list = new();
for (int i = 0; i < 50; i++)
{
if (!list.Contains(lines[i])) // I know Set exists
list.Add(lines[i]);
if (!list.Contains(linesReceived[i]))
list.Add(linesReceived[i]);
}
List<string> list = new();
for (int i = 0; i < 50; i++)
{
if (!list.Contains(lines[i])) // I know Set exists
list.Add(lines[i]);
if (!list.Contains(linesReceived[i]))
list.Add(linesReceived[i]);
}
71 replies