Hi,
I'm trying things in OOP. I have three questions:
1) what should I give as parameter in the line Console.Write(hfd.Prod("Apple", 5)) ? (error: no overload method takes 2 arguments)
2) Console.Write(Prod("Apple", 5)); same error => is line Head hfd = new Head(); then unnecessary? Can i access method Prod directly from Main?
3) Apparently, the line Product obj= new Product(); is not necessary. Why?
Thanks
V
public class Product
{
public string Name { get; set; }
public int Price { get; set; }
}
public class Head
{
static void Main(string[] args)
{
Head hfd = new Head();
Console.Write(hfd.Prod("Apple", 5));
// Console.Write(Prod("Apple", 5)); this gives the same error => no reference to class Head needed?
}
public void Prod(Product p)
{
//Product obj= new Product(); why not necessary?
if (p.Price > 0)
Console.WriteLine("ok");
}
}