Introduction
The C# programming language allows you to create all sorts of robust applications. Suppose you want to write code to perform operations on unpredictable user input. You might want to add logic to handle incorrect input, convert input into a workable format, and perform the correct operation. As your applications grow larger in size, keeping track of your code can quickly become a challenge.
Methods, also called functions, are a key part of keeping code structured, efficient, and readable. A method is a modular unit of code, and a fundamental programming concept. A method is often designed to perform a specific task and contains code to execute that task. The name of a method should clearly reflect its task, which improves code readability. Learning how to use methods will help you build feature-rich applications more quickly.
In this module, you'll learn to create your own methods to perform specific tasks. You'll learn how methods can simplify and shorten code, as well as keep things organized and easy to find.
Learning Objectives
In this module, you will:
- Create your first c sharp method
- Identify parts of code that can be modularized
- Use methods to organize code into specific tasks
Prerequisites
- Experience with basic coding tasks such as instantiating variables, using various data types, and sending output to a console window.
- Experience using Visual Studio Code to create and run simple console applications.
- Experience using C# data types including
int,string,double, and arrays - Experience using
switchstatements,if-elsestatements, andforloops - Experience using
string.Split