Which code segment should you include in the helper method?

You have a helper method named CreateSiteColumn that contains the following code segment.

private static void CreateSiteColumn(SPWeb web, string columnName)
{

}

You need to add a new site column of type Choice to a SharePoint site by using the helper method.

Which code segment should you include in the helper method?

You have a helper method named CreateSiteColumn that contains the following code segment.

private static void CreateSiteColumn(SPWeb web, string columnName)
{

}

You need to add a new site column of type Choice to a SharePoint site by using the helper method.

Which code segment should you include in the helper method?

A.
SPField field = new SPFieldChoice(System.web.Lists[0].Fields, columnName);

B.
web.Fields.Add(columnName, SPFieldType.Choice, true);

C.
web.Lists[0].Fields.Add(columnName, SPFieldType.Choice, True);

D.
web.Lists[0].Views[0].ViewFields.Add(columnName);

Explanation:
MNEMONIC RULE: “web.Fields.Add”

SPFieldCollection.Add Method (String, SPFieldType, Boolean)
http://msdn.microsoft.com/en-us/library/ms472869.aspx



Leave a Reply 0

Your email address will not be published. Required fields are marked *