It doesn't know what a NewRow() is until you attach it. If you look at the
code (in Lutz Roeder's Reflector), you see:
public DataRow NewRow()
{
DataRow row = this.NewRow(-1);
this.NewRowCreated(row);
return row;
}
This merely creates a row for that table. If this is strongly typed, it will
create the right type of row instead of a generic row like this. It knows
about the row when you add it:
internal void AddRow(DataRow row, int proposedID)
{
this.InsertRow(row, proposedID, -1);
}
Now, to the larger question. In general, your parent object has a collection
of children. In the DataTable, it has a RowCollection:
internal readonly DataRowCollection rowCollection;
rows are added to this collection. If you create an object, let's say a user
object that can have multiple addresses:
public class User
{
private AddressCollection addresses;
}
The address collection is like:
public class AddressCollection() : List<Address>
{
}
This is a very simple example, but it shows one way of linking things
together.
Back to "how does one object see another" it is through code.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
********************************************
| Think outside the box! |
********************************************