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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:19:26+00:00 2026-05-14T05:19:26+00:00

According to rule SA1201 in StyleCop elements in class must appear in correct order.

  • 0

According to rule SA1201 in StyleCop elements in class must appear in correct order.
The order is following:

 Fields  
 Constructors  
 Finalizers (Destructors)  
 Delegates  
 Events  
 Enums  
 Interfaces  
 Properties  
 Indexers  
 Methods  
 Structs  
 Classes 

Everything is ok, except of Interfaces part, because Interface can contain methods, events, properties etc…
If we want to be strict about this rule then we won’t have all members of Interface in one place which is often very useful. According to StyleCop help this problem can be solved by splitting class into partial classes.

Example:

/// <summary>
/// Represents a customer of the system.
/// </summary>
public partial class Customer
{
    // Contains the main functionality of the class.
}

/// <content>
/// Implements the ICollection class.
/// </content>
public partial class Customer : ICollection
{
    public int Count 
    { 
        get { return this.count; }
    }

    public bool IsSynchronized 
    { 
        get { return false; }
    }

    public object SyncRoot 
    { 
        get { return null; }
    }

    public void CopyTo(Array array, int index)
    {
        throw new NotImplementedException();
    }
}

Are there any other good solutions to this problem?

  • 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-14T05:19:27+00:00Added an answer on May 14, 2026 at 5:19 am

    I suppose (*) that explicit interface implementations should be grouped together (below events) and the rule applies only to implicit interface implementations. I think the rule makes some sense, because if you’re implementing interface implicitly, it becomes a part of the public interface of the class, so the members of the interface are logically also a part of the class (and so you shouldn’t separate them from the rest of the class).

    On the other hand, if you’re using explicit implementations, you’re saying that you want to implement the interface, without making it a part of the class. In this case, it makes more sense to keep it separately from the rest of the members.

    So, I guess the advice would be to use implicit interface implementations as often as possible (in the cases when it makes sense). For explicit implementations it may feel less inconvenient to use the suggested order.

    That said, if you think it’s better to group the members of an interface together, then I’d probably prefer just ignoring the StyleCop rule instead of using partial classes (which seems like crazy workaround to me). Afterall, StyleCop gives you just an advice…

    (*) If my assumption is wrong, then I would probably just ignore the rule :-).

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

Sidebar

Related Questions

StyleCop has a rule about using this. prefix to calling class members (SA1101). Is
According to the C++11 standard, is the following program well-formed and portable C++? int
I used to have the following rule in my .htaccess while building a website:
According to Google to allow your article/news to appear in Google News: Display a
It came to my attention the following fact : order of function evaluation, for
According to the MySQL documentation: As a general rule, you should never assign a
According to GNU's documentation If there are many included files then the rule is
Here i used auto-release for 'tempString' in the method 'test'. According to the rule,
According to One Definition Rule (ODR) I can't have a function void function() {
I want to merge two files A.xml and map.xml with Node elements according to

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.