ListCollection Class
Represents a collection of List objects.
Inheritance Hierarchy
System.Object
Microsoft.SharePoint.Client.ClientObject
Microsoft.SharePoint.Client.ClientObjectCollection
Microsoft.SharePoint.Client.ClientObjectCollection<List>
Microsoft.SharePoint.Client.ListCollection
Namespace: Microsoft.SharePoint.Client
Assemblies: Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll); Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Syntax
'Declaration
<ScriptTypeAttribute("SP.ListCollection", ServerTypeId := "{1e78b736-61f0-441c-a785-10fc25387c8d}")> _
Public Class ListCollection _
Inherits ClientObjectCollection(Of List)
'Usage
Dim instance As ListCollection
[ScriptTypeAttribute("SP.ListCollection", ServerTypeId = "{1e78b736-61f0-441c-a785-10fc25387c8d}")]
public class ListCollection : ClientObjectCollection<List>
Examples
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);
}
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.