Using an if-else statement to execute alternate code

So far, the if statements have needed certain conditions to be true for the code block to execute. There is an option that allows you to have an alternate code block execute when the if statement conditions are false.

  • If my conditions are met, execute the following code block, else execute the alternate code block

    Note

    This is very simple concept, just like a little kid saying: "If you give me an ice cream cone, I'll be nice, else I'm going to be naughty."

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.