In this blog, I will add a code snippet for deleting an item in a SharePoint announcement list using client object model.
The client object model must conclude with a call to ExecuteQuery() or ExecuteQueryAsync(ClientRequestSucceededEventHandler, ClientRequestFailedEventHandler).
Steps
  1. Open Visual Studio in your system.
  2. Select Console Application template and give it a name.
  3. Add a Microsoft.Client Assembly reference file in the right side Reference tab in Visual Studio.
  4. Replace Program.cs with the source code below.
Code snippet
  1. using System;
  2. using Microsoft.SharePoint.Client;
  3. namespace GowthamArticles
  4. {
  5. class CreateListItem
  6. {
  7. static void Main()
  8. {
  9. ClientContext clientContext = new ClientContext("https://gowtham.sharepoint.com/tutorials");
  10. List oList = clientContext.Web.Lists.GetByTitle("Announcements");
  11. ListItem oListItem = oList.Items.GetById(7);
  12. oListItem["Title"] = "Custom Title updated Programmatically.";
  13. oListItem.DeleteObject();
  14. clientContext.ExecuteQuery();
  15. }
  16. }
  17. }
Thanks for reading.