c# - Best Type to set as return type for methods that return a collection? -


Which is the best type for returning collections?

Did I call IList & lt; T & gt; , IEnumerable & lt; T & gt; , IQueryable & lt; T & gt; , something else? Which is the best and why ?

I am trying to decide how specifically to use the interface and some sections to implement. / P>

Edit Let me close it a bit further, I'm using SQL from LINQ to return data to a WCF service. It seems that there is a change in the best type to use?

I'm shooting the minimal interface to expose the default in IEnumerable IList & Lt; T & gt; and IQueryable & lt; T & gt; Applicable IEnumerable & lt; T & gt; As long as you do not need other specific requirements for the methods, I go for minimalism and use the least derivative type. If your calling code has other requirements, such as the number of items in the display or archive of indexed lookup, you are getting other types like ICollection & lt; T & gt; You may want to select .


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -