DotNet 6.0 Demo

Contents

keyboard_tab
C# Conditional Branching
1
Introduction
PREVIEW1m 32s
2
Overview
PREVIEW1m 12s
7
Summary
2m 15s

The course is part of this learning path

Start course
Overview
Difficulty
Beginner
Duration
20m
Students
36
Ratings
5/5
starstarstarstarstar
Description

 

The ability for software to perform tasks or functions based on the state of variables or data is intrinsic to programming. In plain language, that means responding appropriately to input from the user or some data feed. C# Conditional Branching primarily focuses on If and Switch statements, the main mechanisms for executing or branching to different code depending on whether a condition is true or false. A simple example is allowing users to log in if their username and password match those stored in the software.

Learning Objectives

  • Learn and understand If-statement syntax and how to use it in different scenarios
  • Learn and understand the Switch statement and how to use it 
  • Learn about evaluating multiple Boolean conditions
  • See how the dotnet new command has changed with the release of .NET 6.0 and C# 10

Intended Audience

This course is intended for students that are relatively new to programming but not absolute beginners and want to know how to make their software responsive and adaptive. Students should know the basics of a C# programs structure and have experience running a program within their development environment. While for-loops and object-oriented concepts will be mentioned in the course, in-depth knowledge of these topics isn't essential.

Prerequisites

Demo Source Code

https://github.com/cloudacademy/csharp-conditional-branch

Transcript

Before we get into the if-statement demo, I want to talk briefly about .NET 6, C# version 10, and the new app templates. Here I'm creating a new console app specifying the .NET 6 framework. When I open Visual Studio Code and Program.cs there is just one line writing to the console. This new feature eliminates all the boilerplate code with keywords like program and the using and namespace statements. The latest C# compiler, version 10,  infers the required dependencies and program structure from the type of application you create. 

The rationale is that you, the developer, aren't hampered or distracted by code that adds nothing to your program. I am not a fan. In fact, I find it unsettling. There are a couple of options if you're a bit old-school like me and like the pomp and ceremony of keywords and structure. You can add the use-program-main switch to the dotnet new command. This adds the program class and main function with the namespace, but not enclosed in curly braces and no using statements. Alternately, you can create a .NET 5 application, and in VS Code, change the target framework in the project file. You'll also need to change the output directory in launch.json. Clearly, a stripped-down program.cs is the future, so I'll need to get used to it at some point.

About the Author
Students
20941
Courses
50
Learning Paths
9

Hallam is a software architect with over 20 years experience across a wide range of industries. He began his software career as a  Delphi/Interbase disciple but changed his allegiance to Microsoft with its deep and broad ecosystem. While Hallam has designed and crafted custom software utilizing web, mobile and desktop technologies, good quality reliable data is the key to a successful solution. The challenge of quickly turning data into useful information for digestion by humans and machines has led Hallam to specialize in database design and process automation. Showing customers how leverage new technology to change and improve their business processes is one of the key drivers keeping Hallam coming back to the keyboard. 

Covered Topics