You are creating an application that retrieves values from a custom section of the application configuration file.

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 Class RoleInherits ConfigurationElementFriend _ElementName As String =
    "name"
    <ConfigurationProperty("role")> _
    Public ReadOnly Property Name() As String
    Get
    Return CType(Me("role"), String)
    End Get
    End PropertyEnd Class
B. Public Class Role
    Inherits ConfigurationElement
    Friend _ElementName As String = "role"
    <ConfigurationProperty("name", IsRequired:=True)> _
    Public ReadOnly Property Name() As String
    Get
    Return CType(Me("name"), String)
    End Get
    End PropertyEnd Class
C. Public Class Role
    Inherits ConfigurationElement
    Friend _ElementName As String = "role"
    Private _name As String
    <ConfigurationProperty("name")> _
    Public ReadOnly Property Name() As String
    Get
    Return _name
    End Get
    End PropertyEnd Class
D. Public Class Role
    Inherits ConfigurationElement
    Friend _ElementName As String = "name"
    Private _name As String
    <ConfigurationProperty("role", IsRequired:=True)> _
    Public ReadOnly Property Name() As String
    Get
    Return _name
    End Get 
 End PropertyEnd Class


Answer: B



No comments:

Post a Comment