Last active
November 29, 2017 10:39
-
-
Save luisdeol/6497a7bd682ef2bc789c7c048e6c9d94 to your computer and use it in GitHub Desktop.
Using the for statement to iterate across a collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace implement_program_flow | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var tasks = new[] {"Analyze", "Design", "Code", "Build", "Test", "Blue screen of death", "Deploy"}; | |
for (var i = 0; i < tasks.Length; i++) | |
{ | |
var task = tasks[i]; | |
if (task == "Test") | |
{ | |
Console.WriteLine("Test? Nah, I'm going to skip this... "); | |
continue; | |
} | |
if (task == "Blue screen of death") | |
{ | |
Console.WriteLine("Well, I forgot to push my changes to Git..."); | |
break; | |
} | |
Console.WriteLine($"Task: {task}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment