You are creating an application that retrieves values from a custom section of the application configuration file. The custom section uses XML as shown in the following block.
<ProjectSection name=”ProjectCompany”>
<role name=”administrator” />
<role name=”manager” />
<role name=”support” />
</ProjectSection>
You need to write a code segment to define a class named Role. You need to ensure that the Role class is initialized with values that are retrieved from the custom section of the configuration file. Which code segment should you use?
A.
public class Role : ConfigurationElement
{
internal string ElementName = “name”;
[ConfigurationProperty(“role”)]
public string Name
{
get { return ((string)base[“role”]); }
}
}
B.
public class Role : ConfigurationElement
{
internal string ElementName = “role”;
[ConfigurationProperty(“name”, RequiredValue = true)]
public string Name
{
get { return ((string)base[“name”]); }
}
}
C.
public class Role : ConfigurationElement
{
internal string ElementName = “role”;
private String name;
[ConfigurationProperty(“name”)]
public string Name
{
get { return name; }
}
}
D.
public class Role : ConfigurationElement
{
internal string ElementName = “name”;
private String name;
[ConfigurationProperty(“role”, RequiredValue = true)]
public string Name
{
get { return name; }
}
}