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. SPFeatureCollection featuresCollect = SPContext.Current.SiteFeatures;
featuresCollect.Add(new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), true);
B. SPFeatureCollection featuresCollect = SPContext.Current.WebFeatures;
featuresCollect.Add(new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), true);
C. SPSite web = new SPSite("http://www.contoso.com/hr"); SPFeatureCollection featureCollect = web.Features;
featureCollect.Add(new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), true);
D. SPWeb web = new SPSite("http://www.contoso.com/hr").OpenWeb();
SPFeatureCollection featureCollect = web.Features;
featureCollect.Add(new Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), true);

microsoft-exams

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.