Solved

Linq Filtering

Posted on 2013-12-24
2
373 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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