Introduction

Completed

The applications you'll build in C# will require that you operate on literal and variable numeric data. Examples might include:

  • Performing simple mathematical operations including addition, subtraction, multiplication, and division
  • Performing multi-step operations that must be completed in a certain order
  • Determining the remainder after performing division
  • Incrementing or decrementing a value, and so on

Suppose you want to perform a calculation that converts a value from one unit of measure to another. For example, what if you needed to convert the current temperature from Fahrenheit to Celsius? Once you've calculated the temperature in degrees Celsius, you need to display that information in a formatted message to the user. To accomplish this, you'll need to learn to use operators to act on operands like literal and variable values.

In this module, you'll perform basic string and numeric operations on your data. As you'll learn, the compiler will perform different tasks depending on the data types of the values around the given operator. More importantly, you'll come to understand how operators perform actions on operands. Learning how to work with operators and operands correctly will help you formulate meaningful instructions in your code.

By the end of this module, you will be able to write code that performs basic operations on literal and variable values.

Learning objectives

In this module, you will:

  • Perform mathematical operations on numeric values
  • Observe implicit type conversion between strings and numeric values
  • Temporarily convert one data type into another

Prerequisites

  • Beginner level experience with a .NET editor
  • Beginner level experience with basic C# syntax rules
  • Beginner level experience with displaying a message to a console using the Console.WriteLine and Console.Write methods
  • Beginner level experience with creating literal values and declare variables of basic data types like string, int, and decimal
  • Beginner level experience with string concatenation and string interpolation