Retrieve Parent object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have this (newbie) question, and worse I am not quite sure how to ask it.

My problem is a bit similar as this
With DataTables and Row, one can perfectly write this code, and it makes
some sense.

DataTable myTable = new DataTable("new Table");
DataRow vRow = myTable.NewRow();
myTable.Rows.Add(vRow);
Response.Write(vRow.Table.TableName);

In my Classes I would like to implement a similar thing.

namespace Engine{

public class Offer{
public Offer(){}
//some more code
public string OfferID{
get{}
set{}
}
}

public class Program{
public Program( string OfferID ){}

}
}

So how can I from the class Program, retrieve the parent Offer?

thx
Benoit
 
benoit said:
Hi,

I have this (newbie) question, and worse I am not quite sure how to ask it.

My problem is a bit similar as this
With DataTables and Row, one can perfectly write this code, and it makes
some sense.

DataTable myTable = new DataTable("new Table");
DataRow vRow = myTable.NewRow();
myTable.Rows.Add(vRow);
Response.Write(vRow.Table.TableName);

In my Classes I would like to implement a similar thing.

namespace Engine{

public class Offer{
public Offer(){}
//some more code
public string OfferID{
get{}
set{}
}
}

public class Program{
public Program( string OfferID ){}

}
}

So how can I from the class Program, retrieve the parent Offer?

thx
Benoit

You can pass Offer as an argument in the constructor, something like this:

public class Program
{
private Offer _offer;
public Program(Offer offer)
{
_offer =offer;
}
}

Then , you can access that object in your program.
 
thx
very much newbie question it was...

Jianwei Sun said:
You can pass Offer as an argument in the constructor, something like this:

public class Program
{
private Offer _offer;
public Program(Offer offer)
{
_offer =offer;
}
}

Then , you can access that object in your program.
 

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

Back
Top