Advertisement
karlakmkj

Simple Foreach loop

Nov 20th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ForEachLoop
  4. {
  5.   class Program
  6.   {
  7.     static void Main(string[] args)
  8.     {
  9.       string[] todo = { "respond to email", "make wireframe", "program feature", "fix bugs" };
  10.      
  11.     foreach (string task in todo){   //for each element in the array
  12.       CreateTodoItem(task);   //invoke the method below to print each item in a list
  13.     }
  14.     }
  15.    
  16.     static void CreateTodoItem(string item)
  17.     {
  18.       Console.WriteLine($"[] {item}");
  19.     }
  20.   }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement