Solved

Remove item from List<> using delegates

Posted on 2008-10-22
2
183 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
2 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Call Powershell Script (.ps1)--that requires parameters--from C# 3 39
LINQ question 7 20
c# code 19 56
Achieve json result 2 28
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…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now