I think all that you are missing is a <T> on the Pager - i.e. if this was
public class Pager<T> : Control you would have a type-safe pager, and
itemList would automatically adopt the same T as the T used in Pager. Note,
however, that generic controls don't work very well in the designer; you
will probably need to add them to forms programatically.
The whole point of generics is to provide a re-usable, type-safe construct.
In your example, what objects would the PagingList contain? i.e. what would
it's Add method look like? If you want it accept any type of object, then
that would (as you have found) by PagingList<object>, and it will be
Add(object obj) - however, the main point of generics is that I might want a
strongly typed list of MachinePart objects - i.e. it will accept only
MachinePart objects and subclasses - this would be PagingList<MachinePart>,
and would have Add(MachinePart obj) and the indexer would be "MachinePart
this[int index]" etc.
Does that help?
"PJ" <pj***@hotmail.com> wrote in message
news:tq******************************@speakeasy.ne t...
ok, so apparently i can do:
private PagingList<object> itemList;
which works for my implementation, as I am only concerned w/ the methods
of the subclass PagingList<T> which inherits from List<T>, but I still do
not understand why I cannot use a generic in this situation?
~PJ
"PJ" <pj***@hotmail.com> wrote in message
news:q4********************@speakeasy.net...I have a class defined as so:
public class Pager : Control
{
private PagingList<T> itemList;
...
I'm getting an error message that says, "The type or namespace name 'T'
could not be found. Obviously, I'm just trying to define a class that
PagingList is a class that compiles just fine that inherits from List<T>.
What gives? thx,
~PJ