In C# programming there are two types of functions i.e. system-defining and user-defining, before understanding a user-defined function you need to know what a function is actually.
A function is a code of block either predefined by the system in the class library or written by the user to perform some specific task. In simple words, a group of code combined to perform a desired action or generate some output is called a function.
User Defined Function
A function written by the user to perform a specific action or generate some results is called a user-defined function. Here is an example of a user-defined function.
static void Sum()
{
int x = 50;
int y = 23;
int sum = x + y;
Console.WriteLine($"Sum of {x} and {y} is {sum}");
}