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
Assembly:  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
Public Class ListCollection _
    Inherits ClientObjectCollection(Of List)
'Usage
Dim instance As ListCollection
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.

See also

Reference

ListCollection members

Microsoft.SharePoint.Client namespace