In this tutorial we will learn What are methods? and How to create a method in C# programming language?
Methods
Methods are a way of beautifying your coding style. It allows you to write code once, and use it again and again. It can reduce your 18 lines of execution code to only 12 lines, Wow! Re-usability and manageability is the key purpose of using methods.
Methods are usually verbs. For a student, checkAttendance() can be a method. For a calculator, add() can be a method.
Syntax of a C# method looks like this:
<access specifier> <return type> <method name>(<parameters>){ <body of method> } // Example: An addition method that takes two inputs as parameters and returns output as decimal. public decimal Add(int input1, int input2){ return input1 + input2; }
Methods are created where a piece of code is repeated again and again. Just like a variable in mathematics is used to replace a value.
Methods contain some instructions and algorithms to perform a task and whenever that method is invoked, called or used it will perform that function. So by just writing 1 or 2 line of code, you can repeat maybe 10 lines of code again and again i.e Re-usability of coded
Follow this tutorial in Urdu for learning about methods in C# programming language.
OK I will make very soon
plz make tutorial in C# about enum