Difference , How,check

Posted by Raja_89 under C# on 8/22/2013 | Points: 10 | Views : 730 | Status : [Member] | Replies : 4
Hai
a={12,23,24,67,34}
b={2,4,3}
How to find a-b

using arraylist or any other



Regards




Responses

Posted by: Satyapriyanayak on: 8/22/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
http://stackoverflow.com/questions/6928532/a-better-way-to-find-a-difference-between-two-arrays
http://stackoverflow.com/questions/683310/getting-the-diff-between-two-arrays-in-c

If this post helps you mark it as answer
Thanks

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/22/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Using linq you can do as follows:

var list1 = new string[] {"1", "2", "3", "4", "5", "6"};

var list2 = new string[] {"2", "3", "4"};
var listResult = list1.Except(list2);
foreach (string s in listResult) Console.WriteLine(s);


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/27/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
--To get difference between two arrays in C#
Simply we can do as follows:

var com1 = new string[] {"1", "2", "3", "4", "5", "6"};

var com2 = new string[] {"2", "3", "4"};

foreach (string com in com1 )
{
if (!com2.Contains(com))
{
MessageBox.Show(com);
}
}

http://stackoverflow.com/questions/10991452/how-do-i-get-the-differences-between-two-string-arrays-in-c

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rahmankhan on: 8/27/2013 [Member] Starter | Points: 25

Up
0
Down


var a=new int[] {12,23,24,67,34}

var b = new int[] { 2, 3, 4 };

foreach (var d in a.Except(b).Union(b.Except(a)))
Console.WriteLine(d);

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response