C# Tutorial: Methods
Define and call static methods, use parameters and return values, and understand method overloading.
Methods
Methods are functions inside a class. In C#, `static` methods belong to the class, not an instance.
Later you will see instance methods (on objects). For now, static methods work just like regular functions.
What you'll learn in this C# methods tutorial
This interactive C# tutorial has 8 hands-on exercises. Estimated time: 18 minutes.
- Define and call a method — Static methods in C# are defined inside a class.
- Parameters — Parameters are declared with type and name.
- Return values — Methods can return a value with the `return` keyword. The return type is declared before the method name.
- Method overloading — Multiple methods can share a name if they have different parameter types/counts.
- Optional parameters — Parameters can have default values — callers can omit them.
- Named arguments — Call with argument names to skip optionals or clarify code.
- out parameters — `out` lets a method return multiple values.
- Recursive methods — Methods can call themselves. A base case prevents infinite recursion.
C# Methods concepts covered
- Methods