Solved

Linq Filtering

Posted on 2013-12-24
2
369 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
ID: 39737525
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
ID: 39737682
tht works...thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

912 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

23 Experts available now in Live!

Get 1:1 Help Now