Last active
November 29, 2017 10:39
-
-
Save luisdeol/09650e96069434969a0855fe6f5c28e1 to your computer and use it in GitHub Desktop.
Use the foreach statement to iterate across a colection
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" }; | |
| foreach (var task in tasks) | |
| { | |
| 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}"); | |
| } | |
| Console.ReadLine(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment