Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can we define value from confirmed duplicates in arrays & how C#

Can we define value from confirmed duplicates in 3 4 5 arrays & how?
Probably this is wrong path I take for finding duplicates, but better to ask than to roam
all over my small brain and eventualy delete this and get back to array matrix… I need to extract – define that int value that duplicates and later how much time in each of the 5 rows it exists. So to summarize: How to get that duplicated value "int" so I can use it for later checks.

public void Check() 

{
    var result1 = Row1.Any(L1 => Row2.Contains(L1) && Row3.Contains(L1)) == true;

    var result2 = Row1.Any(L1 => Row2.Contains(L1) && Row3.Contains(L1) && Row4.Contains(L1)) == true;

    var result3 = Row1.Any(L1 => Row2.Contains(L1) && Row3.Contains(L1) && Row4.Contains(L1) && Row5.Contains(L1)) == true;

        if(result3 == true) { result1 = false; result2 = false; Debug.Log("Line 5"); }

        if(result2 == true) { result1 = false; Debug.Log("Line 4"); }

        if(result1 == true) { Debug.Log("Line 3"); }
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If I’m reading your question correctly, you simply want the Intersect extension method, e.g.

int[] id1 = { 44, 26, 92, 30, 71, 38 };
int[] id2 = { 39, 59, 83, 47, 26, 4, 30 };

IEnumerable<int> both = id1.Intersect(id2);

foreach (int id in both)
    Console.WriteLine(id);

/*
 This code produces the following output:

 26
 30
*/
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading