Usually my methods are as the following:
public List Method1(int input)
{
var output = new List();
//add some items to output
It depends.
Do you want the caller to be able to modify the items and for you to see those changes? Arrays can be modified. The IList interface defines methods for modification (but the implementation may not allow it).
Can you elaborate on the FxCop warning?
Kent
I almost always go with List
because it gives me methods that I frequently find the most useful.
One potential negative consequence of returning an IEnumerable
is that any exceptions that get thrown upon enumeration would come from an area of code that could be quite far away from the code that actually built the object, making bug tracking harder.