PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

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;


Leave a Reply