Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linq Filtering

Posted on 2013-12-24
2
Medium Priority
?
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
Rikin Shah earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

597 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