Question about some snippets in an article

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
 
P

Peter Rilling

It contains a "reference" to a collection object (with emphasis on
reference).
 
G

Guest

why pass a ref of the collection? i understand of the datarow but not the
collection?
 
P

Peter Rilling

Good question. From this amount of code, that is something that I cannot
answer. Normally a hierarchical structure will hold a reference to the
parent object, but I do not know why the collection needs to be held.

rodchar said:
why pass a ref of the collection? i understand of the datarow but not the
collection?

rodchar said:
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
 
G

Guest

thanks for the help. in case you're curious:
http://www.microsoft.com/belux/nl/msdn/community/columns/hyatt/ntier2.mspx
Code Snippet 3 & 4 in the article.
rodchar

Peter Rilling said:
Good question. From this amount of code, that is something that I cannot
answer. Normally a hierarchical structure will hold a reference to the
parent object, but I do not know why the collection needs to be held.

rodchar said:
why pass a ref of the collection? i understand of the datarow but not the
collection?

rodchar said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top