© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
11 replies
ægteemil

✅ Apply multiple attributes from custom attribute

Hey. I want to encapsulate some duplicated logic from a custom attribute. Right now I'm decorating endpoints with multiple attributes, and I'd like to be apply to just apply my own custom attribute, and have that attribute apply multiple other attributes.
So my custom attribute would look like this(?):
public class TestAttribute : Attribute
{
    [MyFirstAttribute(name)]
    [MySecondAttribute(name)]
    public TestAttribute(string name)
    {
        Name = name;
    }

    public string Name { get; }
}
public class TestAttribute : Attribute
{
    [MyFirstAttribute(name)]
    [MySecondAttribute(name)]
    public TestAttribute(string name)
    {
        Name = name;
    }

    public string Name { get; }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Set a class attribute result with a custom attribute
C#CC# / help
3y ago
✅ Can custom attributes use interfaces somehow ?
C#CC# / help
13mo ago
Use Custom Attributes with ASP.NET Identity
C#CC# / help
2y ago
❔ Custom validation attribute not displaying validation message
C#CC# / help
4y ago