Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6052329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:55:00+00:00 2026-05-23T07:55:00+00:00

I have an attribute class: <AttributeUsage(AttributeTargets.Property)> _ Public Class DirectoryAttribute Inherits Attribute Private _attribute

  • 0

I have an attribute class:

<AttributeUsage(AttributeTargets.Property)> _
Public Class DirectoryAttribute
    Inherits Attribute

    Private _attribute As String

    Public Sub New(ByVal attribute As String)
        _attribute = attribute
    End Sub

    Public ReadOnly Property Attribute As String
        Get
            Return _attribute
        End Get
    End Property
End Class

And interfaces and classes:

Public Interface IDirentoryEntity
    <DirectoryAttribute("Name")> _
    Property Name As String
End Interface

Public Interface IOrganizationalUnit
    Inherits IDirectoryEntity
End Interface

Public Class OrganizationalUnit
    Implements IOrganizationalUnit

    ' Implementing IOrganizationalUnit here...'
End Class

Public Interface IIdentifiableDirectoryEntity
    Inherits IDirectoryEntity

    <DirectoryAttribute("sAMAccountName")> _
    Property Login As String
End Interface

Public Interface IGroup
    Inherits IIdentifiableDirectoryEntity
End Interface

Public Class Group
    Implements IGroup

    Private _attributes() As String

    ' Implementing IGroup here...'

    Private ReadOnly Property Attributes() As String()
        Get
            If (_attributes Is Nothing) Then
                Dim attr() As DirectoryAttribute = _
                    CType(GetType(Group).GetCustomAttributes(GetType(DirectoryAttribute), True), DirectoryAttribute())

                If (attr Is Nothing OrElse attr.Length = 0 OrElse attr(0) Is Nothing) Then _
                    Return New String(0) { }

                _attributes = New String(attr.Length) { }

                For index As Integer = 0 To attr.Length - 1 Or _attributes.Length - 1 Step 1
                    _attributes(index) = attr(index).Attribute
                Next
            End If

           Return _attributes
        End Get
    End Property
End Class

With that said, shall the Private Property Attributes() As String() not return the values of DirectoryAttribute placed over the interfaces properties as well, since I specify True in the inheritance parameter of the Type.GetCustomAttributes method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:55:01+00:00Added an answer on May 23, 2026 at 7:55 am

    I think there are two main points of confusion:

    1. Your code is looking up attributes on a type, and the attributes are applied to properties. If you want to retrieve the attribute, you’ll need to look them up on a property like Login or Name.
    2. Regardless, there’s a difference between inheritance and implementation. The class Group implements the interface IGroup, so you won’t see any attributes defined on IGroup show up when you ask for inherited attributes on Group. If you want attributes on an interface that a type implements, you’ll need to ask about the interface directly, you can’t go through the type.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<AttributeUsage(AttributeTargets.Property)> _ Private Class CustomAttrib Inherits Attribute Public Property DataTypeLength As Integer End Class
I have a custom Attribute class that I defined as: [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] public
I have the following class: [MetadataAttribute] [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public class ModuleActivationButtonAttribute :
Say I have this class: [AttributeUsage(AttributeTargets.Method)] public class MyAttribute : Attribute { public MyAttribute()
I have custom attribute defined like so: [AttributeUsage(AttributeTargets.Field)] public class EnumDisplayAttribute : Attribute {
I have created my own attribute to decorate my object. [AttributeUsage(AttributeTargets.All)] public class MyCustomAttribute
Let's have a attribute with an int paramter in the ctor [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
I have a C# annotation which is : [AttributeUsage(AttributeTargets.Method)] public class OperationInfo : System.Attribute
I have the following ValidationAttribute class [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public
I have the following custom attribute, which can be applied on properties: [AttributeUsage(AttributeTargets.Property, AllowMultiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.