Foreach
Written by: maffelu , 2009-04-17 07:26:19
class Program
{
public static void Main(string[] args)
{
//Foreach with string
string[] months = new string[]{"January", "February", "March", "April", "May", "June",
"July", "August", "September", "August", "November", "December"};
Console.WriteLine("String:");
foreach(string s in months)
{
Console.WriteLine(s);
}
//Foreach with int
int[] numbers = new int[]{1, 2, 3, 4, 5};
Console.WriteLine("
Int:");
foreach(int i in numbers)
{
Console.WriteLine(i);
}
Console.Read();
}
}
There are no comments on this article.
If you have any question or just want to leave a message, just fill out the form below!
Your e-mail will not be visible in your post, it is for validation reasons only
Maffelu
Creator and admin of MorkaLork.com.
Started programming in HTML back when frames and tables was the way to design a page, moved on to Pascal/Delphi, PHP, javascript/jQuery, VB.NET/C#, Java and C++.
Currently studies .NET (in general) focusing on ASP.NET.