G
Guest
Code Snippet 1
public class CustomerInfoCollection : IList
{
private ArrayList m_alCustomerInfo;
private DataSet m_ds;
public CustomerInfoCollection()
{
m_alCustomerInfo = new ArrayList();
}
public void GetAllCustomers()
{
// Instantiate a Data Layer class to fill the DataSet
// The specific method will fill a DataTable named "Customers"
// See Part 3 for further details.
DCustomers cust = new DCustomers();
m_ds = cust.SelectAllCustomers();
// Iterate on all rows and create an Info object per row
foreach (DataRow dr in m_ds.Tables["Customers"].Rows)
m_alCustomerInfo.Add(new CustomerInfo(this, dr));
}
}
Code Snippet 2
public class CustomerInfo
{
private DataRow m_dr;
private CustomerInfoCollection m_cic;
public CustomerInfo(CustomerInfoCollection coll, DataRow dr)
{
m_cic = coll;
m_dr = dr;
}
}
These snippets are from an article I'm currently reviewing. I just had a
question about what a certain line of code is doing. The line in question is
as follows:
// Iterate on all rows and create an Info object per row
foreach (DataRow dr in m_ds.Tables["Customers"].Rows)
m_alCustomerInfo.Add(new CustomerInfo(this, dr));
When instantiating a new CustomerInfo object, it's passing 2 parms:
CustomerInfo(this, dr)
Does this mean that for each customerinfo object that's added, the object
contains a collection object as well?
thanks,
rodchar
public class CustomerInfoCollection : IList
{
private ArrayList m_alCustomerInfo;
private DataSet m_ds;
public CustomerInfoCollection()
{
m_alCustomerInfo = new ArrayList();
}
public void GetAllCustomers()
{
// Instantiate a Data Layer class to fill the DataSet
// The specific method will fill a DataTable named "Customers"
// See Part 3 for further details.
DCustomers cust = new DCustomers();
m_ds = cust.SelectAllCustomers();
// Iterate on all rows and create an Info object per row
foreach (DataRow dr in m_ds.Tables["Customers"].Rows)
m_alCustomerInfo.Add(new CustomerInfo(this, dr));
}
}
Code Snippet 2
public class CustomerInfo
{
private DataRow m_dr;
private CustomerInfoCollection m_cic;
public CustomerInfo(CustomerInfoCollection coll, DataRow dr)
{
m_cic = coll;
m_dr = dr;
}
}
These snippets are from an article I'm currently reviewing. I just had a
question about what a certain line of code is doing. The line in question is
as follows:
// Iterate on all rows and create an Info object per row
foreach (DataRow dr in m_ds.Tables["Customers"].Rows)
m_alCustomerInfo.Add(new CustomerInfo(this, dr));
When instantiating a new CustomerInfo object, it's passing 2 parms:
CustomerInfo(this, dr)
Does this mean that for each customerinfo object that's added, the object
contains a collection object as well?
thanks,
rodchar