Join Bruce Van Horn for an in-depth discussion in this video Compound logic with logical OR, part of C# Essential Training: 2 Flow Control, Arrays, and Exception Handling.
- [Instructor] So we've seen two different ways…to do this sort of if, else logic structure,…but I alluded, at one point,…that there was a better way to do this.…And you might've thought that I was talking…about the switch statement here on line 13,…but actually, I wasn't.…The problem with this code is it's rather long,…considering we're really only trying…to get down to two possible answers.…So there's actually an easier and faster way to do this,…without writing quite so many lines of code.…So let's write this a different way,…let's write public string, primary…or secondary, and this time we're going to use compound logic.…
So I'll just call this one primary or secondary compound,…so that I can tell the difference.…We'll take our color string as usual,…and what I'm going to do this time…is I'm going to use an if statement,…like I did the first time, but I'm going…to do this with a compound statement.…Which means, I can detect more than one condition…in a single statement.…So I'll say if color dot to lower…equals red, or, and I say or…
AuthorBruce Van Horn
- Writing unit tests in C#
- Working with simple and multidimensional arrays
- Managing ordered and unordered data with lists
- Evaluating conditions with if-else statements
- Using OR, AND, and NOT operators
- Building loops
- Debugging and handling exceptions
- Creating the final build of your C# project
Skill Level Beginner
C# Object-Oriented Programming Tips and Trickswith Jesse Freeman58m 39s Intermediate
1. Unit Testing and Test-Driven Development
2. Arrays and Collections
3. Flow Control
4. Exception Handling
5. Getting to Production
Next steps1m 57s
- 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.