Guest User

3.Методи

a guest
Feb 24th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Методи
  2.  
  3. Method – a named piece of code
  4. Методите вдигат абстракцията. Когато мислим за нещо, което трябва да бъде свършено, може да използваме конкретен метод за това нещо, без да има нужда да разбираме кода в конкретния метод и без дори да гледаме кода в този метод
  5.  
  6. A method can contain optional parameters:
  7. static void PrintNumbersInRange(int start = 0, int end = 14)
  8. {
  9. }
  10.  
  11. PrintNumbersInRange();
  12. PrintNumbersInRange(2, 7);
  13. PrintNumbersInRange(end: 12, start: 8);
  14.  
  15.  
  16. Method return types:
  17. - Type void – does not return a value (only executes code)
  18. - Other types – return values, based on the return type of the method
  19.  
  20. Сигнатура на метод – името на метода и съвкупността от параметри, които приема
  21.  
  22. Method overloading – use the same method name for multiple methods with different parameters
Add Comment
Please, Sign In to add comment