Any existing alorgithm in .NET that can extract the common element in two string arrays to another s

  • Thread starter Thread starter zlf
  • Start date Start date
Z

zlf

Hi,
This there any existing alorgithm in .NET that can extract the common
element in two string arrays to another string array;

usage:
string[] a = { "1","2","3" };
string[] b = { "1" };

string[] c = extractCommonElement ( a , b );

Result:
c = { "1" }

Thx

zlf
 
I am not sure on this, but isn't it very easy to write such a function
yourself if you cannot find one.

Just loop through each element in a, and check whether it's in b or not,
if it is, then add it to c.

Jianwei
 
sounds like homework.

If you make an attempt at the code, and then have a hard time making it
work, post it and we can help you past any syntax issues.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Back
Top