Partager via


ListCollection - Classe

Represents a collection of List objects.

Hiérarchie d’héritage

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.ClientObjectCollection
      Microsoft.SharePoint.Client.ClientObjectCollection<List>
        Microsoft.SharePoint.Client.ListCollection

Espace de noms :  Microsoft.SharePoint.Client
Assemblys :   Microsoft.SharePoint.Client.Silverlight (dans Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client.Phone (dans Microsoft.SharePoint.Client.Phone.dll)  Microsoft.SharePoint.Client (dans Microsoft.SharePoint.Client.dll)

Syntaxe

'Déclaration
Public Class ListCollection _
    Inherits ClientObjectCollection(Of List)
'Utilisation
Dim instance As ListCollection
public class ListCollection : ClientObjectCollection<List>

Exemples

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);

        }
    }
}

Cohérence de thread

Tous les membres statique (Partagé dans Visual Basic)s publics de ce type sont thread-safe. Cela n’est pas garanti pour les membres d’instance.

Voir aussi

Référence

ListCollection - Membres

Microsoft.SharePoint.Client - Espace de noms