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 955479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:23:12+00:00 2026-05-16T00:23:12+00:00

Why annotations doesnt work in interfaces ? like: public interface IUser { [Required] string

  • 0

Why annotations doesnt work in interfaces ?

like:

public interface  IUser
{
    [Required]
    string FirstName { get; set; }
}

now if i made a class to implement that

 public partial class Customer:IUser
{
    public Customer()
    {
    }

    public string FirstName
    {
        get; set;
    }
}

it wouldnt enforce validation unless i mark property in the class too ! so what is the point of annotate it in the interface from the first place ! ! so any idea ?

  • 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-16T00:23:12+00:00Added an answer on May 16, 2026 at 12:23 am

    Well, the simple answer is that there is no point in annotating in the interface. As you’ve noted, calling Attribute.GetAttribute() (even if inherit is true) on a property does not return attributes decorated on the interface properties that your class has implemented. Presumably supporting such a facility would result in the potential for startling ambiguity when multiple interfaces are satisfied by the same implementation.

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

Sidebar

Related Questions

With Data Annotations for example, besides decorating members like this: [Required( ErrorMessage = You
Suppose you have a generic interface and an implementation: public interface MyInterface<T> { void
I would like to use constants for annotation values. interface Client { @Retention(RUNTIME) @Target(METHOD)
What configuration is needed to use annotations from javax.validation.constraints like @Size , @NotNull ,
I have an interface with several method definitions, and I would not like to
I wolud like use DataModel and DataModelSelection annotations in my managing component. @Name(myComponent) @Scope(CONVERSATION)
Consider the following example: public interface Bar { } @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public
my JavaDoc doesn't work when I have a code example with an annotation. Any
Can you override method in java without using annotations? Because eclipse doesn't support it
Removing annotations from my map view in the following way: if ([[self.mapView annotations] count]

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.