SPFieldCollection.GetField Method

Returns the field with the specified internal, display, or static name from the collection.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

[ClientCallableMethodAttribute(Name = "GetByInternalNameOrTitle", CacheReturnValue = true)]
[ClientCallableExceptionConstraintAttribute(FixedId = "a", ErrorType = typeof(ArgumentException), 
	Condition = "The field with the specified internal name or title does not exist in the collection at the given scope.", 
	ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "e", ErrorType = typeof(SPException), 
	Condition = "There is a COM exception which is not a throttle failure or a join throttle failure.", 
	ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "c", ErrorType = typeof(SPQueryThrottledException), 
	Condition = "There is a throttle failure.", ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "b", ErrorType = typeof(UnauthorizedAccessException), 
	Condition = "User does not have permissions to get the field.", 
	ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "d", ErrorType = typeof(SPQueryThrottledException), 
	Condition = "There is a join throttle failure.", ErrorCode = )]
public SPField GetField(
	string strName
)

Parameters

strName
Type: System.String

A string that specifies either the internal, display, or static name of the field.

Return Value

Type: Microsoft.SharePoint.SPField
An SPField object that represents the field.

ExceptionCondition
ArgumentException

The field is not found.

Microsoft SharePoint Foundation searches first by internal name; then, if necessary, by display name; finally, if necessary, by static name.

Show: