SPBuiltInFieldId.Contains Method
Returns a Boolean value that indicates whether or not the specified GUID matches the ID for a built-in field.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Parameters
- fid
- Type: System.Guid
A field identifier.
Return Value
Type: System.Booleantrue if the GUID matches the ID of a built-in field; otherwise false.
The following example is a console application that calls the Contains method twice: first, to verify whether an arbitrary member of the site columns collection is a built-in field; second, to prove that a newly-created field is not a built-in field.
using System; using Microsoft.SharePoint; namespace Test { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://localhost")) { using (SPWeb web = site.RootWeb) { // Test a field from the site columns collection. SPField siteField = web.Fields[0]; FieldTest(siteField); // Create a field and test it. SPField newField = new SPField(web.Fields, SPFieldType.Boolean.ToString(), "New Field"); string internalName = web.Fields.Add(newField); newField = web.Fields.GetFieldByInternalName(internalName); FieldTest(newField); } } Console.Write("\nPress ENTER to continue..."); Console.Read(); } static void FieldTest(SPField field) { if (field == null) throw new ArgumentNullException("field"); Guid fid = field.Id; Console.WriteLine("The field {0} {1} a built-in field.", field.InternalName, SPBuiltInFieldId.Contains(fid) ? "is" : "is not"); } } }