This chapter explained routines, which are named pieces of code that other pieces of code can invoke to perform specific tasks. Routines make programming easier and less error-prone by:

  • Reducing duplicated code

  • Reusing code

  • Simplifying complex code

  • Hiding implementation details

  • Dividing tasks among programmers

  • Making debugging easier

The only real drawback to routines is that a routine call requires some overhead. Because they have many advantages and only one small disadvantage, routines are part of most programs.

Writing and using routines is relatively easy. The only really complicated part is understanding how value and reference types behave when you pass them to a routine by value or by reference. Table 9-2 summarizes the combinations.

Get Start Here!™ Fundamentals of Microsoft® .NET Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.