|
-
Nov 12th, 2009, 01:23 PM
#1
Thread Starter
Frenzied Member
passing generic collection to a method
Hello,
I have a base collection class which implements some things.
public abstract class baseDataCollection <T>
: System.Collections.ObjectModel.KeyedCollection<int, T>,
IDisposable,
IBindingList,
IComponent
where T: baseData
BaseData is an abstract class that deals with reading/writing from the db.
I have another abstract class in a project which adds some more functionality:
public abstract class baseFeedbackLookupsCollection<T> : BaseCore.baseDataCollection<T>
where T : baseLookup
baseLookup inherits baseData.
In my project, I have several collection classes which inherit from baseFeedbackLookupsCollection<T>, and T is replaced with the appropriate type, which also inherits baseData.
I want to have a method that will accept a parameter of type baseFeedbackLookupsCollection<T> and i can pass one of the several collections that inherit this class. That way I can work with the items knowing they all inherit from baseLookup and have certain properties.
Examples.
I have several collection classes that inherit baseFeedbackLookupsCollection:
Departments,
ContactTypes,
ActionTypes
etc....
I want a method
public void SetSource(baseFeedbackLookupsCollection<t> items)
{
foreach(baselookup item in items)
{
do things with the item.
}
}
to call i would use the following:
SetSource(departments)
or
SetSource(contactTypes)
Can someone point me in the right direction?
Thanks,
Don't anthropomorphize computers -- they hate it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|