Wednesday, March 13, 2013

Official guideline of C# for the order of items in terms of class or structure


According to the StyleCop 4.3 Rules Documentation (available from the StyleCop 4.3 download page) the ordering is as follows.
Within a class, struct or interface: (SA1201 and SA1203)
  • Constant Fields
  • Fields
  • Constructors
  • Finalizers (Destructors)
  • Delegates
  • Events
  • Enums
  • Interfaces
  • Properties
  • Indexers
  • Methods
  • Structs
  • Classes
Within each of these groups order by access: (SA1202)
  • public
  • internal
  • protected internal
  • protected
  • private
Within each of the access groups, order by static, then non-static: (SA1204)
  • static
  • non-static
An unrolled list is 130 lines long, so I won't unroll it here. The methods part unrolled is:
  • public static methods
  • public methods
  • internal static methods
  • internal methods
  • protected internal static methods
  • protected internal methods
  • protected static methods
  • protected methods
  • private static methods
  • private methods
hope this will help to programmers who want to write standard code in C#


No comments:

Post a Comment