Solved

Linq Filtering

Posted on 2013-12-24
2
368 Views
Last Modified: 2016-02-10
I am running this code so accordingly it should result in the unmatched items between the 2 arrays

The arr3 is returning me 5.



var arr1 = new int[] { 3, 4, 5 }; // Declare int array
            var arr2 = new int[] { 3, 4};
            var arr3=arr1.Except(arr2);

            Console.WriteLine(arr3.ToString());
            Console.ReadLine();


For arr1 can i first define it as empty...like below and then add a list to this since the items are generated dynamically..but its giving me an error on compile time

var arr1 = new int[] {};
0
Comment
Question by:Moizsaif123
2 Comments
 
LVL 19

Accepted Solution

by:
Rikin Shah earned 500 total points
Comment Utility
Hi,

You can use generics here-

List<int> myInts = new List<int>();
myInts.Add(5);
myInts.Add(10);
myInts.Add(11);
myInts.Count // = 3

Open in new window


And you can get the difference by list1 = list1.Except(list2).ToList(); code.
0
 
LVL 4

Author Comment

by:Moizsaif123
Comment Utility
tht works...thanks.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now