Home > Backend Development > C#.Net Tutorial > The difference between methods and functions in C#

The difference between methods and functions in C#

WBOY
Release: 2023-08-23 16:57:02
forward
1250 people have browsed it

The difference between methods and functions in C#

In C#, methods and functions are the same.

However, with methods in C#, they are functions that operate on a specified 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 a method 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;
   }
   ...
}
Copy after login

The above is the detailed content of The difference between methods and functions in C#. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template