Partilhar via


FieldCollection Class

Represents a collection of Field objects.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.ClientObjectCollection
      Microsoft.SharePoint.Client.ClientObjectCollection<Field>
        Microsoft.SharePoint.Client.FieldCollection

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.FieldCollection", ServerTypeId := "{d449d756-e113-4d27-a5e7-609cbc3eba7e}")> _
Public Class FieldCollection _
    Inherits ClientObjectCollection(Of Field)
'Usage
Dim instance As FieldCollection
[ScriptTypeAttribute("SP.FieldCollection", ServerTypeId = "{d449d756-e113-4d27-a5e7-609cbc3eba7e}")]
public class FieldCollection : ClientObjectCollection<Field>

Examples

This code example displays the available fields in the Announcements list.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class FieldCollectionExample
    {
        static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;
            List targetList = site.Lists.GetByTitle("Announcements");
            FieldCollection collField = targetList.Fields;
            clientContext.Load(
               collField, 
               fields => fields
                  .Include(field => field.Title)
               );
            clientContext.ExecuteQuery();

            Console.WriteLine("The following fields are available in the Announcements list:\n\n");
            foreach (Field myField in collField)
               Console.WriteLine(myField.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

FieldCollection Members

Microsoft.SharePoint.Client Namespace