I have a list that contains something like this:
C12 0402 123456 90
C133 0402 123456 90
C9 0402 123456 90
C132 0603 abcd 0
C54 0603 abcd 0
R FID1 fiducial 0
R FID2 fiducial 0
R FID3 fiducial 0
R FID4 fiducial 0
I would like to check each line in the List and make sure that the duplicates are not added... I tried this but I know there is a logic error in here.
List<string> noDuplicatesList = new List<string>();
foreach (var line in theList)
{
if (!noDuplicatesList.Contains(line.PartNumber)) //This is doing nothing...?
noDuplicatesList.Add(line.Name + " " + line.PartDescription + " " line.PartNumber + " " + line.Rotation);
}
foreach (var line in noDuplicatesList)
{
var splitLine = line.Split(' ');
//Print out statements...
}
Question
How do I remove/skip lines that contain the same value (in the example above 123456
, abcd
, fiducial
) so that it will only print something like this:
C12 0402 123456 90
C132 0603 abcd 0
R FID1 fiducial 0