473,327 Members | 1,997 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,327 software developers and data experts.

Custom Generic List

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 helper methods that are at the list level, for instance, maybe we need to get some type of Average of MyClass's in the list so I have a method Average in the MyClassList class.
One of the problems with this is if I use something like Find or FindAll on my custom list. So, MyClassList.Find() returns a List<MyClass> and not MyClassList. This causes some issues when we're working with the lists in our code.
Another way we though about was to try and get rid of the custom lists altogether because I keep reading that you generally never need an actual list, you can usually just use custom iterators and other nice features.

Now I wonder what about my Average function, I could make it a static method in the MyClass class and just pass in a list, something like

static int Average(IEnumerable<MyClass> mylist)
{...}

But it doesn't seem right because I have a bunch of static functions in my class that really have to do with lists. Could someone maybe point me to some examples? I can get everything to work, but I just can't seem to find an elegant solution that isn't making temporary lists all over.
Jan 20 '08 #1
0 1021

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

Similar topics

0
by: Carl Gilbert | last post by:
Hi I am trying to use a custom attribute that takes in an array or list of custom objects. Ths custom object has a text property and a type property. I have a custom attribute which has a...
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,...
0
by: deathtospam | last post by:
I have a class called StoredProcedureInfo that has four get/set properties: ID, Name, Text and IsChecked. I have created a generic list of this class, populated it and now want to make sure...
2
by: filipk69 | last post by:
Could someone point me in the right direction, please. I have an enum something like this: enum TextFieldType { FieldABC = 3000, FieldXYZ = 3001, ….. ….. }
0
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
2
by: shapper | last post by:
Hello, I am creating a custom web control where one of its properties is a generic list: <Bindable(True), Category("Format"), DefaultValue(""), Localizable(True)Property Features() As...
7
by: Max Odendahl | last post by:
Hi, my own declared class has a stl::list as a member variable. I now need access to those from the outside. Is a custom iterator for my class the best solution for this and how to do this? I...
2
by: gilbert | last post by:
Hello. I am trying to use c# generic to define a class. class MyClass<Twhere T: new(){ } In this definition, MyClass can create T objects with a default constructor. Is there any way to...
7
by: Linda Liu[MSFT] | last post by:
Hi George, I have downloaded your sample solution and built it on my machine. I got a compilation error indicating that the type of "CustomResources" doesn't exist in the following xaml code: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.