M
Mike P
I am playing around with the new C# features, but I am having problems
with initialising an object that contains a collection within it (eg a
customer with several order - see below). Can anybody tell me the
correct syntax?
public List<Customer> GetCustomerList()
{
List<Customer> customerList = new List<Customer>
{
new Customer
{
ID = "ALFKI", Name = "Alfreds Futterkiste", Address =
"Obere Str. 57", City = "Berlin", PostalCode = "12209", Country =
"Germany", Phone = "030-0074321", Fax = "030-0076545",
Orders =
new Order
{
ID = 10643, OrderDate =
Convert.ToDateTime("25/08/1997"), Total = 814.50
}
}
};
return customerList;
}
with initialising an object that contains a collection within it (eg a
customer with several order - see below). Can anybody tell me the
correct syntax?
public List<Customer> GetCustomerList()
{
List<Customer> customerList = new List<Customer>
{
new Customer
{
ID = "ALFKI", Name = "Alfreds Futterkiste", Address =
"Obere Str. 57", City = "Berlin", PostalCode = "12209", Country =
"Germany", Phone = "030-0074321", Fax = "030-0076545",
Orders =
new Order
{
ID = 10643, OrderDate =
Convert.ToDateTime("25/08/1997"), Total = 814.50
}
}
};
return customerList;
}