Join Gerry O'Brien for an in-depth discussion in this video Testing conditions with if, part of Learning C# (2014).
Moving right along from our looping structure,…let's take a look at our decision structures.…We have a couple that we're going to focus on.…We have an if, we have an else if, and then we have a switch statement.…Let's look at the if statement first.…And in here, what we're doing is we're creating a…Boolean variable called result, and we're setting it equal to true.…Now, the thing that's interesting about Boolean variables is…that C# automatically knows that it's a Boolean type.…So, when I choose equals and I start to…type, C# knows that I'm looking for a Boolean type.…
And you can see that it highlights it in blue.…So, it knows that it's a keyword as well.…So our if structure, as we take a look at it, it starts off with the keyword if.…And we're checking for what result says in here.…So we're checking for a value.…We're, we're doing a conditional check on something in the parentheses.…If it's true, it will execute the code that is…within the curly braces, and in our case we also added…an else clause to this if statement which says if result…
- Installing C#
- Working with loops
- Controlling program flow
- Using variables
- Building functions
- Creating and instantiating classes
- Catching errors
- Managing resources with the garbage collector
- Building collections
Skill Level Beginner
1. Introducing C#
2. C# Language Elements
3. Object-Oriented Programming in C#
4. Structured Exception Handling
5. Resource Management in C#
6. Extensible Types in C#
7. Windows Apps in C#
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.