Local function
Try it yourself →Defines your own command.
Syntax
ReturnType Name(params) { return ...; }Description
Defined with a return type (void = none), name, and parameters. return gives the result back. Local functions can be defined directly in top-level programs.
Example
using System;
int Square(int x) {
return x * x;
}
Console.WriteLine(Square(5));Expected output
25
When to use?
Preventing code repetition, breaking the program into parts.