Is there any difference in below statement or are they same?

SPListItem[field_Name] vs SPListItem.Properties[field_Name]

Where field_Name is column name in a sharepoint list.

And which one is better to use in reference to optimaztion


Both are different. SPListItem.Properties is a hashtable which can be used to store key value pairs. It is also known as List item property bag in SharePoint.

In ASP.Net web application, whenever we need configuration data (key-value pair), we store that data in web.config file in AppSetting and retrieve configurations from config according to our need. Like AppSetting, SharePoint provides property bag at each level for your SharePoint Application Development SharePoint provides Property bags to store and retrieve configuration at various levels like:

  1. Farm Level - SPFarm
  2. Web Application Level - SPWebApplication
  3. Web Level - SPWeb Level
  4. Item Level - SPListItem

Whereas SPListItem[field_Name] is used to get/set value of a field in a SharePoint List item. Example to store value in list item property bag:

using (SPSite site = new SPSite("http://aissp2013/sites/Team"))
    SPWeb web = site.RootWeb;
    SPList list = web.Lists["Employees"];
    SPListItem item = list.GetItemById(1);
    item.Properties.Add("Employee Name", "Nadeem Yousuf");

See more at http://www.tekritisoftware.com/using-sharepoint-property-bag-in-your-sharepoint-application

| improve this answer | |
  • Could you please specify the scenarios where they are used them? – nbi Dec 19 '14 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.