ListCollection 类

表示List对象的集合。

继承层次结构

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

命名空间:  Microsoft.SharePoint.Client
程序集:   Microsoft.SharePoint.Client.Silverlight(位于 Microsoft.SharePoint.Client.Silverlight.dll 中);  Microsoft.SharePoint.Client.Phone(位于 Microsoft.SharePoint.Client.Phone.dll 中)  Microsoft.SharePoint.Client(位于 Microsoft.SharePoint.Client.dll 中)

语法

声明
Public Class ListCollection _
    Inherits ClientObjectCollection(Of List)
用法
Dim instance As ListCollection
public class ListCollection : ClientObjectCollection<List>

示例

此代码示例创建两个新的公告列表,并将它们添加到当前网站的列表集合。

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

        }
    }
}

线程安全性

该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。

另请参阅

引用

ListCollection 成员

Microsoft.SharePoint.Client 命名空间