.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Compare two Array string using C#.net

Posted By: Narayanan     Posted Date: June 12, 2012    Points:5   Category :C#
Hi,
How to compare two array string using C#.net?
Eg:
string[] com1 = { "COM6", "COM7" };
string[] com2 = { "COM6", "COM7","COM8" };

Here com1 and com2 are Array string.
Result:
COM8.
How to achieve this?

Responses
Author: Narayanan             
Posted Date: June 12, 2012     Points: 20   

Hi friends,
I solve my problem. This is a solution.
 foreach (string com in com2 )
{
if (!com1.Contains(com))
{
MessageBox.Show(com);
}
}



Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Syed Shakeer Hussain             
Posted Date: July 07, 2012     Points: 20   

Hi,
another solution

string[] com1 = { "COM6", "COM7" };

string[] com2 = { "COM6", "COM7", "COM8" };

for (int i = 0; i < com1.Length; i++)

{
for (int j = 0; j < com2.Length; j++)

{

if (com1.ToString() == com2[j].ToString())

{



}

}

}



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend