?
Solved

Linq Filtering

Posted on 2013-12-24
2
Medium Priority
?
382 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

764 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