By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

iterating List<T> of a base class from derived class

P: n/a
phl
Hi,

I have a base class which inherits List<T>, how do I iterate this class
from the calling class? Do I have to use enumerater? Does anyone have
any code samples?

Thx
phl

base class:
abstract class FStatement<T> : List<T>
{

}

calling class:

class BStatement : FStatement<LI> //LI is another class see below
{
public BStatement()
{
this.dispdata();
}

public void dispdata()
{
//how do I do this?
}

}
class LI
{
private string sData1;

public string Data
{
get
{
return sData1;
}

set
{
sData1 = value;
}
}
}

May 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
phl napisaƂ(a):
Hi,

I have a base class which inherits List<T>, how do I iterate this class
from the calling class? Do I have to use enumerater? Does anyone have
any code samples?

Thx
phl

base class:
abstract class FStatement<T> : List<T>
{

}

calling class:

class BStatement : FStatement<LI> //LI is another class see below
{
public BStatement()
{
this.dispdata();
}

public void dispdata()
{
//how do I do this?
}

}
class LI
{
private string sData1;

public string Data
{
get
{
return sData1;
}

set
{
sData1 = value;
}
}
}

[PD] Try:
foreach(LI l in this)
//display l;

--
Piotr Dobrowolski
Piotr.Dobrowolski_usun_gmail.com
May 4 '06 #2

P: n/a
Hi,
class BStatement : FStatement<LI>
So the calling class derive from your base class which in turn derive from
List , are you sure this is the intended way?

Anyway , you can do:

foreach( LI li in this )
...

"phl" <ki************@hotmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com... Hi,

I have a base class which inherits List<T>, how do I iterate this class
from the calling class? Do I have to use enumerater? Does anyone have
any code samples?

Thx
phl

base class:
abstract class FStatement<T> : List<T>
{

}

calling class:

class BStatement : FStatement<LI> //LI is another class see below
{
public BStatement()
{
this.dispdata();
}

public void dispdata()
{
//how do I do this?
}

}
class LI
{
private string sData1;

public string Data
{
get
{
return sData1;
}

set
{
sData1 = value;
}
}
}

May 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.