2- no you dont, but you can create any sort of constructor with any number/combination of the Customer class, if you realise you need it! :)
3- You need to have a structure that hold Customers, ie a List of Customers.
Example:
List<Customer> listCustomers = new List<Customer>();
...then you must add custumers to the list:
listCustomers.Add(cust1);
....
You can always override ToString() in the Customer class
public override string ToString()
{
return "Customer "+NAME; //example!
}
and finally create a foreach loop to write each customer
foreach(Customer cust in listCustomers)
{
Console.WriteLine(cust.ToString());
}
4-I dont think that is possible, a constructor is a data type initializer, so in order to initialize a data object of type Customer, you need to use the Customer contructor!
ze.espogeira
Member
383 Points
101 Posts
Re: It is the right way to do so: Constructor
Jan 31, 2012 08:50 AM|LINK
Hi,
in my opinion,
1- yes
2- no you dont, but you can create any sort of constructor with any number/combination of the Customer class, if you realise you need it! :)
3- You need to have a structure that hold Customers, ie a List of Customers.
Example:
List<Customer> listCustomers = new List<Customer>();
...then you must add custumers to the list:
listCustomers.Add(cust1);
....
You can always override ToString() in the Customer class
public override string ToString()
{
return "Customer "+NAME; //example!
}
and finally create a foreach loop to write each customer
foreach(Customer cust in listCustomers)
{
Console.WriteLine(cust.ToString());
}
4-I dont think that is possible, a constructor is a data type initializer, so in order to initialize a data object of type Customer, you need to use the Customer contructor!
Hope it helps