Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tend to use <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="noreferrer">Microsoft StyleCop</a>, which has a set order according to rule <a href="http://stylecop.soyuz5.com/SA1201.html" rel="noreferrer">SA1201</a>:</p> <blockquote> <p><strong>Cause</strong> An element within a C# code file is out of order in relation to the other elements in the code.</p> <p><strong>Rule Description</strong> A violation of this rule occurs when the code elements within a file do not follow a standard ordering scheme. </p> <p>To comply with this rule, elements at the file root level or within a namespace must be positioned in the following order:</p> <ul> <li>Extern Alias Directives</li> <li>Using Directives</li> <li>Namespaces</li> <li>Delegates</li> <li>Enums</li> <li>Interfaces</li> <li>Structs</li> <li>Classes</li> </ul> <p>Within a class, struct, or interface, elements must be positioned in the following order:</p> <ul> <li>Fields</li> <li>Constructors</li> <li>Finalizers (Destructors)</li> <li>Delegates</li> <li>Events</li> <li>Enums</li> <li>Interfaces</li> <li>Properties</li> <li>Indexers</li> <li>Methods</li> <li>Structs</li> <li>Classes</li> </ul> <p>Complying with a standard ordering scheme based on element type can increase the readability and maintainability of the file and encourage code reuse. </p> <p>When implementing an interface, it is sometimes desirable to group all members of the interface next to one another. This will sometimes require violating this rule, if the interface contains elements of different types. This problem can be solved through the use of partial classes.</p> <ol> <li><p>Add the partial attribute to the class, if the class is not already partial.</p></li> <li><p>Add a second partial class with the same name. It is possible to place this in the same file, just below the original class, or within a second file.</p></li> <li><p>Move the interface inheritance and all members of the interface implementation to the second part of the class.</p></li> </ol> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload