C# Methods
A method is a reusable block of code. Declare a return type (void if nothing), a name and parameters. Call it by name.
Example
static int Add(int a, int b) { return a + b; }
static void Greet(string name) => Console.WriteLine("Hello " + name);
Console.WriteLine(Add(2, 3));
Greet("Ada");Exercise
Return nothing.
static Hi() {}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.