using Microsoft.SharePoint.Client; // Create a ClientContext object and authenticate with SharePoint ClientContext context = new ClientContext("https://yoursharepointsite.com"); context.Credentials = new SharePointOnlineCredentials("username", SecureStringPassword); // Create a new list using the ListCreationInformation object and add it to the site ListCreationInformation listCreationInfo = new ListCreationInformation(); listCreationInfo.Title = "New List"; listCreationInfo.TemplateType = (int)ListTemplateType.GenericList; List newList = context.Web.Lists.Add(listCreationInfo); ` `context.ExecuteQuery();
using Microsoft.SharePoint.Client; // Create a ClientContext object and authenticate with SharePoint ClientContext context = new ClientContext("https://yoursharepointsite.com"); context.Credentials = new SharePointOnlineCredentials("username", SecureStringPassword); // Get the list where you want to add the new item List list = context.Web.Lists.GetByTitle("List Title"); // Create a new list item and set its properties ListItemCreationInformation listItemCreationInfo = new ListItemCreationInformation(); ListItem newListItem = list.AddItem(listItemCreationInfo); newListItem["Title"] = "New Item Title"; newListItem["Description"] = "New Item Description"; // Save the new item to the list and execute the query to update SharePoint newListItem.Update(); context.ExecuteQuery();These examples are just a few of the many actions that can be taken using the ClientContext class in C#. Developers can use this library to do things like create new sites, add/update/delete list items, and more.