C# Programming: Lesson 5. Validation
YouTube Viewers YouTube Viewers
205K subscribers
1,268 views
0

 Published On Jun 11, 2023

This is the fifth in a series of computer science lessons about programming with C# for beginners. In this lesson you will learn how to use the if statement to validate input from the user, thereby making it less likely that your application will crash. Input validation is an important aspect of defensive design. By building an application that will convert a temperature from Fahrenheit to Celsius or from Celsius to Fahrenheit, you will learn how to perform different kinds of validation checks including presence checks, data type checks, length checks, range checks and format checks. You will also meet the TryParse method which can be used to test if it is possible to cast a string as a number before attempting to do so. In addition, you will see how radio buttons can be used to collect user input. The importance of consistent code indentation and layout is also explained, particularly when nesting one if block inside another.

Chapters:
00:00 Introduction
02:53 The need for validation
03:32 Presence check
04:33 Data type check with TryParse
08:06 Length check
09:12 Range check
11:00 Format check
11:28 Radio buttons
13:05 Nested if blocks
14:50 The importance of consistent indentation
16:00 Testing the validation checks

show more

Share/Embed