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#.
class NumberManipulator { public int FindMax(int num1, int num2) { /* local variable declaration */ int result; if (num1 > num2) { result = num1; }else { result = num2; } return result; } ... }
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!