tags:

views:

21

answers:

1

Hi All,

Can u please explain me which is fast and why or any other option to fast call any list

1) web.GetList(String.Format("{0}/Lists/{1}/AllItems.aspx", web.Url, listname))

2) web.lists[listname]

Thanks

A: 

Its impossible to really know without digging out reflector and profiling tools since the documentation doesn't tell us but generally you would expect the 1st to be more efficient.

The reason is that SPWeb.GetList is getting one SPList object from SharePoint.

However web.lists is getting a SPListCollection containing ALL lists in the web and you are then finding the one you want with [listName] (see overloaded Item property)

Ryan