Which code segment should you use?

You are creating a Web Part. The Web Part will be used in a SharePoint subsite that has the URL
http://www.contoso.com/hr. You need to ensure that the Web Part activates a Feature in the

subsite without causing a memory leak. Which code segment should you use?

You are creating a Web Part. The Web Part will be used in a SharePoint subsite that has the URL
http://www.contoso.com/hr. You need to ensure that the Web Part activates a Feature in the

subsite without causing a memory leak. Which code segment should you use?

A.
SPWeb web = new SPSite(“http://www.contoso.com/hr”).OpenWeb(); SPFeatureCollection
featureCollect = web.Features; featureCollect.Add(new
Guid(“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”), true);

B.
SPSite web = new SPSite(“http://www.contoso.com/hr”); SPFeatureCollection featureCollect =
web.Features; featureCollect.Add(new Guid(“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”), true);

C.
SPFeatureCollection featuresCollect = SPContext.Current.SiteFeatures;
featuresCollect.Add(new Guid(“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”), true);

D.
SPFeatureCollection featuresCollect = SPContext.Current.WebFeatures;
featuresCollect.Add(new Guid(“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”), true);



Leave a Reply 0

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