Current .Net Version: 1.1.4322
Home
Articles
Practice C# Online
C# Reference
XML Web Services
RSS Feeds
T-SQL Scripts
Videos
Valuable Links
Contact Us
Mike's C#, VS.NET and SQL Blog
ROR XML Info.
C# Reference
The world's largest C# Language & Framework Class Library Reference Database (second only to Microsoft's)!
Language Reference:
Language Search:
Framework Class Library Reference:
Framework Class Library Search:

foreach
Is a:Statement Keyword
Applies to Version:C# 1.0 and later
Namespace:N/A
Assembly:N/A (N/A)
Description:Continuosly executes a statement (or b034f00a-e6f9-4bb8-847a-845bb940ebeas) for each element in an array or an collection. foreach can iterate through a collection only when it implements the IEnumerable interface OR defines a Current property, GetEnumerator() and MoveNext() method.
Syntax:
foreach (type identifier in expression) statement
MSDN:http://msdn.microsoft.com/library/en-us/csref/html/vclrfTheForeachStatement.asp?frame=true
Example(s):String[] arrString = new String[] { "1st", "2nd", "3rd" }; foreach (String s in arrString) { MessageBox.Show(s); // this will execute 3 times }
 
COPYRIGHT/DISCLAIMER | CONTACT US