473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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
2 1681
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: matty.hall | last post by:
I have two classes: a base class (BaseClass) and a class deriving from it (DerivedClass). I have a List<DerivedClass> that for various reasons needs to be of that type, and not a List<BaseClass>....
3
by: Eric | last post by:
I have a string representation of an object. I create an object of that type through reflection. I would like to create a List<> of those objects. I obviously can't do List<myObject.GetType()>...
5
by: PJ | last post by:
I have a class definition : public class PagingList<T> : List<T> { private int pageSize, pageNumber; public PagingList() { pageSize = (this.Count == 0) ? 1 : this.Count;...
6
by: Jeff.Boeker | last post by:
I'm learning a lesson in how I need to be more specific :) In C++ I can resize a vector and it will allocate memory and it will call the default constructor if necessary (or I can supply an...
9
by: Paul | last post by:
Hi, I feel I'm going around circles on this one and would appreciate some other points of view. From a design / encapsulation point of view, what's the best practise for returning a private...
0
by: submicron | last post by:
Hi All, I'm having problems implementing a readonly interface to a set of classes. Heres a simplification of the code: interface IreadonlyBase { // Does gets only on base class } class...
7
by: Andrew Robinson | last post by:
I have a method that needs to return either a Dictionary<k,vor a List<v> depending on input parameters and options to the method. 1. Is there any way to convert from a dictionary to a list...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume...
4
by: Peted | last post by:
I have the following code public enum pdfFlags { PFD_DRAW_TO_WINDOW, PFD_DRAW_TO_BITMAP, PFD_SUPPORT_GDI, PFD_SUPPORT_OPENGL, PFD_GENERIC_ACCELERATED, PFD_GENERIC_FORMAT,
35
by: Lee Crabtree | last post by:
This seems inconsistent and more than a little bizarre. Array.Clear sets all elements of the array to their default values (0, null, whatever), whereas List<>.Clear removes all items from the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.