C#, Programming, and Software Development

C# Lesson 3 — Calling Methods

Methods are the building blocks of C# programs. Learn how to call them with parameters and handle their return values.

Randy Runtsch
5 min readSep 19, 2021

--

Photo by Maxwell Nelson on Unsplash

Introduction

Methods, sometimes called functions or procedures, are the building blocks of most computer programs. Ideally, to keep programs clean and easily understood, they will be compact and perform one primary task. In the C# language, as in C and C++, each method can be called with zero or more input parameters (values — also called arguments) and can optionally return one value.

This article will show you how to perform these tasks in C#:

  • Write a method that accepts no input parameters and does not return a value.
  • Write a method with one or more parameters and does not return a value.
  • Write a method with one or more parameters with default values and no return value.
  • Write a method that returns a value.

Preparing the Programming Environment

For this article, I wrote the example programs on the Windows operating system with the free Microsoft Visual Studio Community…

--

--

Randy Runtsch

Writer | Photographer | Outdoor Lover | Adventure Cyclist | Business Owner | Data Analyst | Software Developer