I have one question. I have to do a method that fills a List < object > from a sql database. My question is:
It’s better to do this:
List<Product> listProducts = new List<Product>();
listProducts = loadProducts();
//this code is in other class
public List<Product> loadProducts()
{
List<Product > listProduct = new List<Product> ();
//code
return listProduct
}
Or it’s better this:
List<Product> listProducts = new List<Product>();
listProducts = loadProducts(listProducts);
//this code is in other class
public List<Product> loadProducts(List<Product> listProduct)
{
//Code
return listProduct
}
Sorry if it’s a noob question but both of two works but I don’t know which is more improved.
Thanks a lot.
Go for this