Separate content and example (#22468)
* Separate content and example * Fixed formatting
This commit is contained in:
@ -9,11 +9,13 @@ The `foreach` loop executes a block of code for each item in a collection. The b
|
|||||||
### Example
|
### Example
|
||||||
```csharp
|
```csharp
|
||||||
|
|
||||||
|
// syntax
|
||||||
foreach (element in iterable-item)
|
foreach (element in iterable-item)
|
||||||
{
|
{
|
||||||
// body of foreach loop
|
// body of foreach loop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sample code
|
||||||
List<string> Names = new List<string>{ "Jim", "Jane", "Jack" }
|
List<string> Names = new List<string>{ "Jim", "Jane", "Jack" }
|
||||||
|
|
||||||
foreach(string name in Names)
|
foreach(string name in Names)
|
||||||
|
Reference in New Issue
Block a user