Solved

Remove item from List<> using delegates

Posted on 2008-10-22
2
189 Views
Last Modified: 2008-10-22
Using C# and VS2005 in an ASP.NET project I need to remove an item from a list<>. Here's what I've got so far.  The problem is my list is based on a custom object (PartnerRecord) so I'm trying to use delegates to create a record to remove, but I'm open to anything.


            List<PartnerRecord> results = Session["FilteredPartners"] as List<PartnerRecord>;

                        results.Remove(delegate(PartnerRecord pr1)
                        { return pr1.ID.Equals(ResultsGrid.Items[i].KeyValues.ToString(), StringComparison.CurrentCultureIgnoreCase); });
0
Comment
Question by:eshurak
[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 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22779163
you have to do it as described in the following EE question
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_23593154.html
0
 
LVL 3

Author Comment

by:eshurak
ID: 22781607
Thanks Ragi,

The problem was in my delegate.


PartnerRecord pr = results.Find(delegate(PartnerRecord pr1) { return pr1.ID.Equals(ResultsGrid.Items[i].KeyValues.Substring(5,36)); });
results.Remove(pr);

Open in new window

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 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