C#C
C#4y ago
Majestic

Blazor component - specify list parameter in markup

If I wanted to make a component in Blazor that displayed the sum from a list of integers, is there anyway to specify that list in the markup / razor page?

For example:

<SumComponent> <IntList> 1 2 3 </IntList> </SumComponent>

And the component would have a parameter something like this:

[Parameter] public List<int> IntList {get; set;}

And the actual razor file for the SumComponent would be something like:

<p>The Sum is @(IntList.Sum())</p>
Was this page helpful?