I'm a new C# programmer, and am wondering why I'm getting a object does not contain a definition of 'methodName' and no extension method 'methodName' accepting a first argument of type 'object' could be found error. I'm not sure why it seems the two classes aren't connected.
Here is the class with my method definitions:
namespace Simple_Restaurant_Simulation
{
class ChickenOrder
{
public int quantity;
public int GetQuantity(int ChickenQuantity)
{
this.quantity = ChickenQuantity;
return quantity;
}
public void CutUp()
{
return;
}
public void Cook()
{
return;
}
}
}
and the calling methods:
namespace Simple_Restaurant_Simulation
{
class Employees
{
public dynamic NewRequest(int Quantity, string MenuItem)
{
if (MenuItem == "Chicken")
{
return new ChickenOrder();
}
else
{
return new EggOrder();
}
}
public dynamic CopyRequest(dynamic MenuItem)
{
/*TODO:
if(existing order){
return existing order;
}
else { return "Whaddaya think I am, a miracle worker?"};
*/
return null;
}
public int Inspect(object Order)
{
int InspectResult = 0;
return InspectResult;
}
private string PrepareFood(object Order)
{
string PrepareResult = null;
try
{
if (Order is ChickenOrder)
{
for (int i=0; i < this.GetQuantity; i++)
{
Order.CutUp();
}
Order.Cook();
PrepareResult = "Chicken order has been cooked";
}
return PrepareResult;
}
catch (Exception)
{
}
}
}
}
Thanks for your help
Ordervariable? The use of theisoperator doesn't change that...dynamicorobject. Dynamic is mainly for specific interop scenarios. Get a real compile-time type in there.