Difference between Method and Function in C#



Methods and Functions are the same in C#.

However, Methods are used in C# and are functions that operate through a designated class. A method is a group of statements that together perform a task. Every C# program has at least one class with a method named Main.

The following is a simple example showing how to create methods in C#.

Example

class NumberManipulator {    public int FindMax(int num1, int num2) {       /* local variable declaration */       int result;       if (num1 > num2) {          result = num1;       }else {          result = num2;       }       return result;    }    ... }
Updated on: 2020-06-23T11:40:18+05:30

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements