473,783 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom Generic List

5 New Member
I've got a coding standard question for generic lists and .NET 2.0.

I have created some custom strongly typed lists like, MyClassList:Lis t<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.Fin d() 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(IEnumer able<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 1051

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

Similar topics

0
2183
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 constructor that takes a class as follows: ======================================================= Public Class MyAttribute Inherits System.Attribute
7
5523
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, would return the value of obj because it returns the index of the item at position obj. Thoughts I had were to let the default method perform the default behavior and then create an overload as IndexOf(int index, ProductSearchCriteria criteria)...
0
896
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 certain values exist in it. =================================== protected List<StoredProcedureInfostoredProcedureList = new List<StoredProcedureInfo>(); ===================================
2
2293
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
3466
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 IUserCollectionType to my custom list, which I did. But I still get an error when trying to read the object: " {"Unable to cast object of type 'NHibernate.Collection.Generic.PersistentGenericBag`1' to
2
1178
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 Generic.List(Of Feature) Get If CStr(ViewState("Features")) Is Nothing Then Return String.Empty
7
3838
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 would like to sort the list according to different criteria before, so I would like to offer different iterators, which then sort first based on the type of iterator constructed. Any code sample or link would be nice.
2
3892
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 set the constraint such that MyClass
7
10916
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: <Expander Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type res:CustomResources}, ResourceId=CustomExpanderStyle1}}" >
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.