473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

C# Custom Generic List Predicate Question

I have a class that overrides the List<T> generic class and I'm trying to use the FindAll method. I have it working fine, but the method returns a List<T> not a MyList. I guess it's easier to explain with some code.

public class MyList : List<MyItem>

MyList ml = new MyList();
ml = GetAList();

I want to do the following,
ml = ml.FindlAll(Predicate);

The problem is that FindAll returns List<T> and I can't do a cast like this,
ml = (MyList)ml.FindAll(Predicate)

Is there a way to do this?
Apr 9 '07 #1
1 2154
Motoma
3,237 Expert 2GB
You will need to overload your FindAll method.
Expand|Select|Wrap|Line Numbers
  1. MyList FindAll(...)
  2. {
  3.     return (MyList)this.FindAll(...);
  4. }
  5.  
Apr 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Xah Lee | last post by:
another functional exercise with lists. Here's the perl documentation. I'll post a perl and the translated python version in 48 hours. =pod parti(aList, equalFunc) given a list aList of...
1
by: Isaac | last post by:
Hello, I'm using the Generic List class in System.Collection.Generics to implement a strongly-typed list of my own class. I want to implement the Find methods and have to use the Predicate...
3
by: Michael Rockwell | last post by:
I am new to using C# generics and I am liking what I am finding. However the examples in online help are lacking. Can someone help me with the FindAll method of the generic List class? As I...
3
by: Abhi | last post by:
In the following hypothetical example I want to build a generic list of unique string items. How should I implement the pred function so that it returns true/false if target string exists in the...
7
by: Dale | last post by:
I have a design question. I am creating a custom collection of products. The unique key for the products is productId which is an integer. By default, IndexOf(object obj), when obj is an int,...
3
by: Allan Bredahl | last post by:
Hi All I'm trying to use a Generic.List declared as follows (Example): Public Class MyObj { Public String Name; Public Integer Age; }
7
by: Abhishek | last post by:
Hi I am using a generic list in my program to have a list of objects stored. I want to compare all the objects in this list with object of another class and find all the objects which meet the...
0
by: jappenzeller | last post by:
I've got a coding standard question for generic lists and .NET 2.0. I have created some custom strongly typed lists like, MyClassList:List<MyClass>. We did this because we wanted to reuse some...
7
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I have a Class "Multidictionary" which I created which is basically a dictionary which can have multiple values for the same key. The class centers around private Dictionary<K,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.