Chapter 2
We Have Our Methods
IN THIS CHAPTER
Defining a method
Passing arguments to a method
Getting results back
Reviewing the WriteLine() method
Programmers need to be able to break large programs into smaller chunks that are easy to handle. For example, some programs contained in previous chapters of this minibook reach the limit of the amount of programming information a person can digest at one time. Many developers use rules like being able to see all the code for a particular task on a single monitor screen or printed piece of paper. The idea is that it's hard to keep scrolling back and forth to see what a particular piece of code does.
This chapter looks at methods, which is one way to split code into smaller pieces. C# lets you divide your class code into methods. A method is equivalent to a function, procedure, or subroutine. C# 7.0 and above supports something called a local function, which is really a method in disguise, but it lurks inside another method (the terminology appears to just confuse matters — that’s right, take a deep breath and move on). The difference ...
Get C# 10.0 All-in-One For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.