fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@ -0,0 +1,30 @@
---
title: Foreach Loop
---
## Foreach Loop
The `foreach` loop executes a block of code for each item in a collection. The benefit of the `foreach` loop is you need not know how many items are within the collection to iterate through it; you simply tell your `foreach` loop to loop through the collection, as long as there are items within it. It is useful for iterating through lists, arrays, datatables, IEnumerables and other list-like data structures. It can be less efficient than a very well designed `for` loop, but the difference is negligible in most cases.
### Example
```csharp
foreach (element in iterable-item)
{
// body of foreach loop
}
List<string> Names = new List<string>{ "Jim", "Jane", "Jack" }
foreach(string name in Names)
{
Console.WriteLine("We have " + name);
}
```
### Output:
```sh
> We have Jim
> We have Jane
> We have Jack
```