petre ricardo

petre ricardo

  • NA
  • 194
  • 0

How do i access the member of another class from aclass through a reference object?

Mar 9 2010 1:51 AM

Hi friends,
I have written the followin two classes in mY BLL:
 

 
public class InventoryItem
{

public int MinOrderQuantity { get; set; }
public int MaxOrderQuantity { get; set; }

internal MasterItemInventory myMasterItemInventory;
public ItemStockLevel _MyItemStockLevel;

public InventoryItem()
{
try
{
myMasterItemInventory =
new MasterItemInventory();
_MyItemStockLevel =
new ItemStockLevel();
}
catch
{
throw;
}
}
public byte Save()
{
try
{
 
return myMasterItemInventory.Save(this);
}
catch
{
throw;
}
}
}
 
public class ItemStockLevel
{
public int ItemID { get; set; }
public int StockTakeDate { get; set; }
public int QIS { get; set; }
public ItemStockLevel()
{
//no code
}
public byte Save()
{
//no code
}
}

 

The above two classse are within the same namesapce BLL
then i tried to access the members of ItemStockLevel from the reference myIventoryItem.MyItemStockLevels from my client app as:
using BLL:
public class Form{
private void btnSave_Click(object sender, EventArgs e)
{

myIventoryItem._MyItemStockLevel.StockTakeDate =
int.Parse(cmbStockTakeDate.Text);
byte scode = myIventoryItem.Save();
}
}
the line :
myIventoryItem._MyItemStockLevel.StockTakeDate = int.Parse(cmbStockTakeDate.Text);

gives the followig error
 
Error 1 'ICSBLL.InventoryItem' does not contain a definition for '_MyItemStockLevel' and no extension method '_MyItemStockLevel' accepting a first argument of type 'ICSBLL.InventoryItem' could be found (are you missing a using directive or an assembly reference?) F:\C#\Lab\InventoryControlSystem\InventoryControlSystem\frmInventoryItemAdmin.cs 60 36 InventoryControlSystem

Why this happense and how do i fix this?

Answers (3)