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

How can you choose a line that fulfills all the conditions?

How do we know the number of common values between two lines from two different tables? using csharp.

table1.row[1]={5,6,3,4,1}

 table2.row[3]={6,4,16,18,7,'2'}

// table2.row[3][5] is char mean number of duplicate value must be to return true (i make it char because i dont want program use this
value whenthey do comparison)//

in this two table the funcion need to return true
because we have two duplicate number and its the same value given by user in table2.row[3][5]

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

>Solution :

There are many ways to find duplicates.

Here’s one that doe not use anything C# specific.

var a = new [] {5,2,3,4,1};
var b = new [] {2,4,16,18,'2'};


List<object> commonElements =  new(); // You can also just count 'duplicates'
for(int i = 0; i < a.Length; i++)
    for(int j = 0; j < b.Length; j++)    
        if(b[j] == a[i]) 
        {   
            commonElements.Add(a[i]); 
            break;
        }
Console.WriteLine(string.Join(",",commonElements));

This prints 2,4.

Later you can

if(commonElements.Count == user_input)
{
    ...
}

BTW. Please note that '2' and 2 would not be considered the same.

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