Difference between Method and Function in C#

CsharpProgrammingServer Side Programming

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#.


class NumberManipulator {
   public int FindMax(int num1, int num2) {
      /* local variable declaration */
      int result;
      if (num1 > num2) {
         result = num1;
      }else {
         result = num2;
      return result;
Published on 18-Sep-2018 11:29:21