ListCollection class
SharePoint Online
Represents a collection of List objects.
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ClientObjectCollection
Microsoft.SharePoint.Client.ClientObjectCollection<List>
Microsoft.SharePoint.Client.ListCollection
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ClientObjectCollection
Microsoft.SharePoint.Client.ClientObjectCollection<List>
Microsoft.SharePoint.Client.ListCollection
Namespace: Microsoft.SharePoint.Client
Assembly: Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
This code example creates two new announcements lists and adds them to the list collection of the current web site.
using System; using Microsoft.SharePoint.Client; namespace Microsoft.SDK.SharePointFoundation.Samples { class ListCollectionExample { static void Main() { string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(siteUrl); Web site = clientContext.Web; ListCollection collList = site.Lists; ListCreationInformation lci1 = new ListCreationInformation(); lci1.Title = "New Announcements"; lci1.TemplateType = (int)ListTemplateType.Announcements; site.Lists.Add(lci1); ListCreationInformation lci2 = new ListCreationInformation(); lci2.Title = "Old Announcements"; lci2.TemplateType = (int)ListTemplateType.Announcements; site.Lists.Add(lci2); clientContext.Load(collList); clientContext.ExecuteQuery(); Console.WriteLine("Lists on the current site:\n\n"); foreach (List targetList in collList) Console.WriteLine(targetList.Title); } } }
Show: