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.

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="ProjectBraindumps">
<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 ref class Role : public ConfigurationElement {
    protected :
    static String^ _ElementName = “name”;
    public :
    [ConfigurationProperty("role")]
    property String^ Name {
    String^ get() {return ((String^)base[“role”]);}
    }};

B. public ref class Role : public ConfigurationElement {
    protected :
    static String^ _ElementName = “role”;
    public :
    [ConfigurationProperty("name", IsRequired = true)]
    property String^ Name {
    String^ get() {return ((String^)base[“name”]);}
    }};
C. public ref class Role : public ConfigurationElement {
    private :
    String^ _name;
    protected :
    static String^ _ElementName = “role”;
    public :
  [ConfigurationProperty("name")]
    property String^ Name {
    String^ get() {return_name;}
    }};
D. public ref class Role : public ConfigurationElement {
    private :
    String^ _name;
    protected :
    static String^ _ElementName = “name”;
    public :
    [ConfigurationProperty("role", IsRequired = true)]
    property String^ Name {
    String^ get() {return_name;}
    }};

Answer: B

No comments:

Post a Comment