C# MethodsLesson 21Free preview
C# Methods
This lesson is part of C# · All levels
Summary
A method is a named block of code that performs a specific task and can be called over and over from a variety of places. Static methods are called by the class name without creating objects. The method can return values via return or simply run a task with a void type.
Key points
- How to declare: type the method name and its parameters, then call it by name and argument.
- Void means that the method does not return any value.
- Static methods are called by the name of the class without having to make objects first.
- The method reduces code duplication and makes the program more structured.
- Stop the method execution and return the value to the caller.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.