Write reusable code in C#

Beginner
Developer
Higher Education Educator
K-12 Educator
Student
.NET

Learn how to write reusable code in C# using methods, parameters, return values, variable scope, and namespaces.

Learning objectives

After you complete this module, you'll be able to:

  • Create methods that accept parameters

  • Return values from methods

  • Understand how variable scope affects your code

  • Organize code using namespaces and the using directive

Prerequisites

  • Beginner level experience with basic C# syntax rules

  • Beginner level experience with creating literal values and declaring variables of basic data types like string, int, and decimal

  • Beginner level experience with evaluating Boolean expressions and using if, else if, and else statements

  • Beginner level experience with repeating actions using for, while, and do-while loops

  • Beginner level experience with storing data using arrays and List<T>