Simple
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] MyNums = { 1, 2, 3, 4, 5 };
foreach (int i in MyNums)
{
if (i == 3) break;
Console.WriteLine(i);
}
Console.ReadKey();
}
}
}
This should only print 1 and 2 to the console.
Reputation Points: 2023
Solved Threads: 644
Senior Poster
Offline 3,736 posts
since Oct 2008