I am making a library which is going to be used widely by different applications. You can say that it is sort of a public library or SDK.
Currently I am working on a function which takes a list of Points performs some calculation on these points and then return list of updated points. So my question here is what should I use as return type and in my parameters. IList
, IEnumerable
or Collection
.
So here it the function. I am unaware what user will do with the output. How user uses it, is on him. So what should be best option to use here.
public static IEnumerable<Point2D> PeformSomeCalculation(IEnumerable<Point2D> points)
{
// Do something,
return updatedPoints;
}
The
IList<T>
interface inherits fromICollection<T>
,IEnumerable<T>
andIEnumerable
.So if you return an
IList<T>
, clients that want anICollection<T>
, anIEnumerable<T>
or just anIEnumerable
will all be happy.