[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

C# Linq Remove All

Posted on 2016-08-09
2
Medium Priority
?
228 Views
Last Modified: 2016-08-10
Is there a shorter way to write this so no  looping is involved?
                        for (int i = 0; i < data.Count; i++)
                        {
                            myObject.RemoveAll(x => x.Name == data[i].Name &&
                                                  x.Description == data[i].Description;
                        }

Open in new window

0
Comment
Question by:CipherIS
[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 10

Accepted Solution

by:
Prakash Samariya earned 2000 total points
ID: 41749937
Try linq code like below:
myObject.RemoveAll(
	x => data.Exists(
		y=> { 
			y.Name ==x.Name && y.Description==x.Description
		}
	)
);

Open in new window

0
 
LVL 1

Author Comment

by:CipherIS
ID: 41750968
Thanks that work with minor modification.
myObject.RemoveAll(
		x => data.Exists(
				y => y.Name == x.Name && 
				y.Description == x.Description
                  )
);

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 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