070-573 Free Dumps Study Materials
Question 13: You deploy a custom Web Part named WebPart1 to a SharePoint site.
WebPart1 contains the following code segment. (Line numbers are included for reference only.)
01 protected void Page_Load(object sender, EventArgs e)02 {
03 04 05 06 07 08
SPSite site = null;try{ SPSite site = new SPSite("http://www.contoso.com/default.aspx");SPWeb web
= site.OpenWeb();
09
...
10
11
}catch
12
13
{
14
15
16
17
}finally{
18
}
19 }
After you deploy WebPart1, users report that the pages on the site load slowly.
You retract WebPart1 from the site.
Users report that the pages on the site load without delay. You need to modify the code in
WebPart1 to prevent the pages from loading slowly.
What should you do?
A. Add the following line of code at line 08:
site.ReadOnly = true;
B. Add the following line of code at line 13:
site.Dispose();
C. Add the following line of code at line 17:
site.Dispose();
D. Add the following line of code at line 17:
site.ReadOnly = true;
Correct Answer: C
Explanation: MNEMONIC RULE: "finally dispose"
Disposing Objects http://msdn.microsoft.com/en-us/library/ee557362.aspx