[Blazor] Components - loop samples - intro text removal (#33675)

pull/33679/head
Robert Haken 2024-09-23 02:04:30 +02:00 committed by GitHub
parent 4911282c39
commit e044b737a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 0 additions and 4 deletions

View File

@ -1270,8 +1270,6 @@ Consider the following `RenderFragmentChild2` component that has both a componen
When rendering the `RenderFragmentChild2` component in a parent component, use a local index variable (`ct` in the following example) instead of the loop variable (`c`) when assigning the component parameter value and providing the child component's content:
```razor
<h1>Three children with a <code>for</code> loop and an index variable</h1>
@for (int c = 1; c < 4; c++)
{
var ct = c;
@ -1285,8 +1283,6 @@ When rendering the `RenderFragmentChild2` component in a parent component, use a
Alternatively, use a [`foreach`](/dotnet/csharp/language-reference/keywords/foreach-in) loop with <xref:System.Linq.Enumerable.Range%2A?displayProperty=nameWithType> instead of a [`for`](/dotnet/csharp/language-reference/keywords/for) loop:
```razor
<h1>Alternative approach without an index variable</h1>
@foreach (var c in Enumerable.Range(1, 3))
{
<RenderFragmentChild2 Id="@($"Child{c}")">