?
Solved

Remove item from List<> using delegates

Posted on 2008-10-22
2
Medium Priority
?
195 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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