Advertisement
desislava_topuzakova

Methods: Demo

Feb 18th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. namespace Demo
  2. {
  3. internal class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7.  
  8. PrintMessage();
  9.  
  10. PrintInRange();
  11.  
  12. String text = "9";
  13.  
  14. PrintInRange();
  15. PrintMessage();
  16.  
  17. Console.WriteLine("asdadas");
  18. PrintMessage();
  19. int number = 9;
  20. number += 9;
  21.  
  22. PrintInRange();
  23. PrintMessage();
  24.  
  25. PrintGreaterNumber(56, 87);
  26. }
  27.  
  28. static void PrintInRange()
  29. {
  30. for (int i = 0; i < 10; i++)
  31. {
  32. Console.WriteLine("Test23423423");
  33. }
  34. }
  35. static void PrintMessage()
  36. {
  37. Console.WriteLine("This operation is succesfull!!!!!!!");
  38. }
  39.  
  40. static void ModifyNumber()
  41. {
  42.  
  43. }
  44.  
  45. //static -> лесно да извиквам метода чрез неговото име
  46. //видове методи:
  47. //1. void -> отпечатва стойност или да модифицира стойност
  48. //2. връщат резултат
  49.  
  50. //име на метода
  51. //1. PascalCase -> първата буква е главна и всяка следващта дума е също с главна буква
  52. //2. EN
  53. //3. Какво прави метода?
  54.  
  55. //СЪЗАДАВАНЕ НА МЕТОД: static + вид на метода (void / връща резулатат) + име на метода + (параметри)
  56.  
  57. static void PrintGreaterNumber (int number, int number2)
  58. {
  59. if (number > number2)
  60. {
  61. Console.WriteLine(number);
  62. }
  63. else
  64. {
  65. Console.WriteLine(number2);
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement