I know that private fields are first. Where should the other members be located according to the C # code style?
I mean: private / protected / internal / public fields / properties / methods / events. I always posted events in the last part of the lesson. Sometimes I use a private method near a public property that uses it. I do not think this is a suitable place, but I cannot choose a place for it and for many other participants.
According to StyleCop (style check done by Microsoft), the correct order is:
Adjacent elements of the same type should be arranged in the following order by access level:the publicinteriorprotected internalreserved- SA1202
Adjacent elements of the same type should be arranged in the following order by access level:
- SA1202
SA1201, (.. , - ,...).
StyleCop : http://stylecop.codeplex.com/releases/view/44839
(. , " " ). .
, , , , ( , , , ) #region - #endregion.
, , , , , , .
,
. , . , .
:
// Class layout based on accessibility class Purchasing { #region Main #region Public #region Internal #region Protected #region Private #region Extern #region Designer Generated Code }
o .
o , .
o , Visual Studios, . , .
, .
Do what ever suits you, just be consistent.
I think that if you do not mess up your code, confuse everything and combine all this, you can choose which order you prefer.
As long as you agree with this, there is no correct order.
Source: https://habr.com/ru/post/1796259/More articles:Is there an implementation of this string matching method in python? - pythonHow to populate Controller.Request in ASP.NET MVC - asp.net-mvc-3Get TDataModule in development mode - delphiMagento does not show all categories in admin - adminhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1796258/convert-xls-to-xlsm-using-excelcnvexe&usg=ALkJrhgUqelOg6kSKNRd1rx9HG78iOdPRgHow many Java objects are generated by this - new String ("abcd") - javaIs it possible to play only part of an mp3 file using AVAudioPlayer? If so, how? - iosКаково точное преимущество использования тега над тегом? - htmlEditing files in place with a tie acting differently on different Unix - linuxHow can I organize controls on a form relative to each other and the form itself? - c #All Articles