[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

OOP Question about .NET Framework

jmDesktop

6/12/2008 3:09:00 PM

In the .NET framework, how does one class "see" another class? For
example, in the DataTable class there is a method called NewRow(). It
returns an object type DataRow. But how does DataTable know about
DataRow? I guess this is more fundemental than .net. How does a
framework no about the objects inside of it?
3 Answers

Cowboy

6/12/2008 5:14:00 PM

0

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...list...

or just read it:
http://gregorybeamer.spaces...

********************************************
| Think outside the box! |
********************************************
"jmDesktop" <needin4mation@gmail.com> wrote in message
news:93e72623-d93b-4f4b-8130-ad29e2e2455c@a70g2000hsh.googlegroups.com...
> In the .NET framework, how does one class "see" another class? For
> example, in the DataTable class there is a method called NewRow(). It
> returns an object type DataRow. But how does DataTable know about
> DataRow? I guess this is more fundemental than .net. How does a
> framework no about the objects inside of it?

Jack Jackson

6/12/2008 9:03:00 PM

0

On Thu, 12 Jun 2008 08:09:26 -0700 (PDT), jmDesktop
<needin4mation@gmail.com> wrote:

>In the .NET framework, how does one class "see" another class? For
>example, in the DataTable class there is a method called NewRow(). It
>returns an object type DataRow. But how does DataTable know about
>DataRow? I guess this is more fundemental than .net. How does a
>framework no about the objects inside of it?

Any class can "see" any other classes that are in scope. Those other
classes might be Public classes on other assemblies to which the
current project has a reference, they might be Friend or Public
classes in the same project, or they might be Private classes
contained in the class.

DataTable only "knows" about DataRow because there is code in
DataTable that uses DataRow. The designer of the DataTable class
decided that the class that is used to represent rows in the DataTable
is DataRow, and coded accordingly, including defining the NewRow
method as:
Public Function NewRow As DataRow

Tim

6/12/2008 9:37:00 PM

0


Hi,

My question is about the Microsoft .NET Framework 3.5; I was wondering how
do i open the configuation program so i can give access to it. It seems to
block the registery, which it won't run the program at. I cant find the
Microsoft .NET Framework configuation program. i'm using windows vista Home
Premium
64-bit with SP 1

v/r

Tim