I'm having a problem, I don’t even know what to look for in Google / Stack Overflow. So comment if you feel the need for further explanation, questions.
Basically, I want to cross two lists and return the resemblance to the saved order of the original value of the first row.
Example:
I have two lines that I convert to CharArray. I want to cross these two arrays and return values that are similar , including / with the order of the first line (s1) .
As you can see, the first line contains E15 (in that particular order) as well as seconds.
So these two lines will return: {'E', '1', '5'}
string s1 = "E15QD(A)";
string s2 = "NHE15H";
The problem I am facing is that if I replaced "s2" with:
string s2 = "NQE18H" // Will return {'Q', 'E', '1' }
My operation will return: {'Q', 'E', '1'}
The result should be: {'E', '1'}, because Q does not follow the letter 1
Currently, my work is not the biggest effort, because I do not know what methods to use in .NET to do this.
Current code:
List<char> cA1 = s1.ToList();
List<char> cA2 = s2.ToList();
var result = cA1.Where(x => cA2.Contains(x)).ToList();
Feel free to help me, pointers in the right direction are acceptable, as well as a complete solution.