Chapter 4: Adding behavior into our apps


Overview

This session explores how to add behaviors into your C# applications through the use of methods. It begins with a reminder of classes, fields and methods and then goes through the process of defining a method, calling a method, passing parameters, returning values, and method overloading. The exercises enable you to put these concepts into practice through building a simple calculator.

Objectives

  1. Create a class with methods to provide behavior
  2. Utilize properties to hide our fields

Exercises
Exercise 4.1 Building a Calculator
In this lab, you will define aCalculatorclass with some methods to perform simple arithmetic operations.

Exercise 4.2 Adding onto our Calculator
Here, you will add some new behavior into your calculator by adding an overloaded method to perform modulo division (finding the remainder).

Exercise 4.3 Working with properties
In this final exercise, you will hide the field details through the use of properties and auto-properties.

results matching ""

    No results matching ""