SPContentType.Fields property

Gets an SPFieldCollection that represents collection of column references included in the content type.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public ReadOnly Property Fields As SPFieldCollection
    Get
'Usage
Dim instance As SPContentType
Dim value As SPFieldCollection

value = instance.Fields
public SPFieldCollection Fields { get; }

Property value

Type: Microsoft.SharePoint.SPFieldCollection
The collection of columns used by the content type.

Remarks

For more information about columns, see Introduction to Columns.

The SPContentType object contains both a SPFieldLinkCollection and an SPFieldCollection object.

The SPFieldCollection object provides developers a way to get a combined view of a column's attributes, as they exist in that content type. Each SPField object represents all the attributes of a column, or field, definition, merged with those attributes that have been overridden in the field reference for that content type.

When you access a SPField in a content type, SharePoint Foundation merges the field definition with the field reference, and returns the resulting SPField object to you. This prevents developers from having to look up a field definition, and then look up all the attributes in the field definition that are overridden by the field reference for that content type.

Because of this, there is a 1-to-1 correlation between the items in the SPFieldLinkCollection and SPFieldCollection objects. For each SPFieldLink object that you add to a content type, SharePoint Foundation adds a corresponding SPField object that represents the combined view of that column as it is defined in the content type.

You cannot directly add or delete items from an SPFieldCollection object in an SPContentType object; if you try to do this, an error is thrown.

See also

Reference

SPContentType class

SPContentType members

Microsoft.SharePoint namespace

Other resources

Introduction to Columns

Adding Columns in Content Types to Lists

Introduction to Content Types

Site and List Content Types

Base Content Type Hierarchy