T
TonyJ
Hello!
Assume I have a declared the generic class PrintableCollection<T> in this
way see below.
Here I use a restriction on the type parameter T that this type T must
implement the interface IPrintable which have method Print.
So there is a restriction set on the elements that can be stored in the
generic class PrintableCollection<T> which is that
those elements must implement the interface IPrintable.
Assume that I want to store Circles in the generic class
PrintableCollection<T>
So in this case the type Circles must implement the interface IPrintable.
Now to my question: Whithin the generic class PrintableCollection<T> I must
use some kind of collection
object that give me the possibility to actually store these Circles objects.
What is the best suitable collection object to use ?
I assume that to use a generel object like ArrayList is not a good choice do
you agree with me?
A better choice I assume is to use a generic class event here?
So how should I declare this collection object in the generic class
PrintableCollection<T>?
public class PrintableCollection<T> where T : IPrintable
{
....
....
}
//Tony
Assume I have a declared the generic class PrintableCollection<T> in this
way see below.
Here I use a restriction on the type parameter T that this type T must
implement the interface IPrintable which have method Print.
So there is a restriction set on the elements that can be stored in the
generic class PrintableCollection<T> which is that
those elements must implement the interface IPrintable.
Assume that I want to store Circles in the generic class
PrintableCollection<T>
So in this case the type Circles must implement the interface IPrintable.
Now to my question: Whithin the generic class PrintableCollection<T> I must
use some kind of collection
object that give me the possibility to actually store these Circles objects.
What is the best suitable collection object to use ?
I assume that to use a generel object like ArrayList is not a good choice do
you agree with me?
A better choice I assume is to use a generic class event here?
So how should I declare this collection object in the generic class
PrintableCollection<T>?
public class PrintableCollection<T> where T : IPrintable
{
....
....
}
//Tony