Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Форматиране на кода
- В C# при конструкции като if клаузата, след самата дума if има празно място и отварящата скоба е точно под първата буква на конструкцията. След отварящата скоба задължително има някакъв символ, т.е. няма празен ред или празно място)
- if (some condition)
- {
- …
- }
- for (int k = 0; k < 10; k++)
- {
- …
- }
- In Java, JavaScript
- if (some condition) {
- …
- }
- there is exactly one empty line after method declaration
- there is exactly one blank space when we make a comment:
- // some comment
- Always use curly brackets (for if-clauses, for loops, etc.)
- When we write methods they look like:
- In C#:
- There is no blank space between the name of the method and the opening bracket
- private static uint CalcFactorial(uint num,_int someNumber)
- {
- …
- }
- In JavaScript:
- function nameOfTheFunction(someVariable)_{
- …
- }
- When we call methods:
- In C#:
- RegisterUser(“nakov”, “password”);
- - there is no blank space between the name of the method and the opening bracket
- in JavaScript:
- someFunction(“nakov”, “password”);
- Use an empty line to separate logically related sequences of lines of code.
- Order of definitions in classes, interfaces, structures:
- 1.constants
- 2.delegates
- 3.inner types (enums, inner classes)
- 4.fields
- 5.constructors
- 6.properties
- 7.methods
- static members
- none static members:
- public members
- protected members
- internal members(available to be used only in the current project)
- private members
- public class Dog
- {
- // Constants(static members)
- public const string Species = “Canis Lupus Familiaris”;
- // Instance variables
- private int age;
- // Constructors
- public Dog(string name, int age)
- {
- this.Name = name;
- this.age = age;
- }
- // Properties
- public string Name { get; set; }
- // Methods
- public void Breathe()
- {
- }
- }
- After the body of a construction(if-clause, for loop, etc.) there should be an empty line
- If-clauses:
- In C#:
- if (matrix[x, y] == 0 ||
- matrix[x – 1, y] == 0||
- matrix[x – 1, y - 1] == 0||
- matrix[x – 1, y] == 0)
- {
- …
- }
- In JavaScript(double tab):
- if (matrix[x, y] == 0 ||
- matrix[x – 1, y] == 0||
- matrix[x – 1, y - 1] == 0||
- matrix[x – 1, y] == 0) {
- …
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement