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

  • Home
  • SEARCH
  • 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 7842441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:19:22+00:00 2026-06-02T16:19:22+00:00

Attribute code [AttributeUsage(AttributeTargets.Property, Inherited = true)] class IgnoreAttribute : Attribute { } Base class

  • 0

Attribute code

[AttributeUsage(AttributeTargets.Property, Inherited = true)]
class IgnoreAttribute : Attribute
{
}

Base class

abstract class ManagementUnit
{
    [Ignore]
    public abstract byte UnitType { get; }
}

Main class

class Region : ManagementUnit
{
    public override byte UnitType
    {
        get { return 0; }
    }

    private static void Main()
    {
        Type t = typeof(Region);
        foreach (PropertyInfo p in t.GetProperties())
        {
            if (p.GetCustomAttributes(typeof(IgnoreAttribute), true).Length != 0)
                Console.WriteLine("have attr");
            else
                Console.WriteLine("don't have attr");
        }
    }
}

Output: don't have attr

Explain why this is happening? After all, it must inherited.

  • 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-06-02T16:19:23+00:00Added an answer on June 2, 2026 at 4:19 pm

    The inherited flag dictates whether the attribute can be inherited.
    The default for this value is false. However, if the inherited flag is
    set to true, its meaning depends on the value of the AllowMultiple
    flag. If the inherited flag is set to true and the AllowMultiple flag
    is false, the attribute will override the inherited attribute.
    However, if the inherited flag is set to true and the AllowMultiple
    flag is also set to true, the attribute accumulates on the member.

    from http://aclacl.brinkster.net/InsideC/32ch09f.htm
    Check the chapter Specifying Inheritance Attribute Rules

    EDIT: check Inheritance of Custom Attributes on Abstract Properties
    The first answer:

    It’s the GetCustomAttributes() method that does not look at parent
    declarations. It only looks at attributes applied to the specified
    member.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is really unbelievable but real. This code will not work: [AttributeUsage(AttributeTargets.Property|AttributeTargets.Field)] public class
I've created the following attribute: [Serializable] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited =
I have defined a custom attribute [AttributeUsage(AttributeTargets.Property )] public class FieldAttribute: Attribute { public
I have custom attribute defined like so: [AttributeUsage(AttributeTargets.Field)] public class EnumDisplayAttribute : Attribute {
Let's have a attribute with an int paramter in the ctor [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
There are two attributes like this: [AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = true)] sealed
I have a simple PostSharp logging attribute: [Serializable] public class MethodLoggingAttribute : OnMethodBoundaryAspect {
The following code rearranges elements by the attribute amount. How can I alter this
This code returns an error: AttributeError: can't set attribute This is really a pity
The xmlns attribute in the following code stops me getting the value I need.

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.