Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 684 Bytes

GCop148.md

File metadata and controls

53 lines (45 loc) · 684 Bytes

GCop 148

"All constructors should be before all methods in a class."

Rule description

According to the StyleCop Rules Documentation the ordering of items in a class is as follows:

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

Example

public partial class Banner
{
    public void MyMethod() 
    {
        ...
    }
    public Banner()
    {
        ...
    }       
}

should be 🡻

public partial class Banner
{
    public Banner()
    {
        ...
    } 
    public void MyMethod() 
    {
        ...
    }
}