Which code segment should you use?

You have a SharePoint site that has the URL http://contoso.com/hr.
You are creating a new Web Part.
You need to create a reference to the current subsite without having to dispose of any returned objects.
Which code segment should you use?
A. SPSite siteCollection = new SPSite("http://www.contoso.com");
SPWebCollection site = siteCollection.AllWebs;
B. SPSite siteCollection = new SPSite("http://www.contoso.com");
SPWeb site = siteCollection.RootWeb;
C. SPSite site = SPContext.Current.Site;
D. SPWeb site = SPContext.Current.Web;

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.