Re: Constructor in sublass of List<>
- From: "David Browne" <davidbaxterbrowne no potted meat@xxxxxxxxxxx>
- Date: Fri, 13 Jan 2006 18:34:22 -0600
"PJ" <pjwal@xxxxxxxxxxx> wrote in message
news:vdudnbR1cP332VXeRVn-uA@xxxxxxxxxxxxxxxx
>I have a class definition :
>
> public class PagingList<T> : List<T>
> {
> private int pageSize, pageNumber;
> public PagingList()
> {
> pageSize = (this.Count == 0) ? 1 : this.Count;
> pageNumber = 1;
> }
>
>
> My problem is that this.Count is 0, apparently the list items aren't
> available in the constructor. Is it possible to get access to the list
> items in the constructor?
>
>
No the object isn't constructed yet so it can't have had items added to it
already.
But you can add a parameter to the constructor.
EG:
public class PagingList<T> : List<T>
{
private int pageSize, pageNumber;
public PagingList(int pageSize)
{
this.pageSize = pageSize;
this.pageNumber = 1;
}
David
.
- References:
- Constructor in sublass of List<>
- From: PJ
- Constructor in sublass of List<>
- Prev by Date: Re: Constructor in sublass of List<>
- Next by Date: Re: How to stop updating DLLs?
- Previous by thread: Re: Constructor in sublass of List<>
- Next by thread: Re: Constructor in sublass of List<>
- Index(es):
Relevant Pages
|