© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
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>
<SumComponent>
     <IntList>
            1
            2
            3
     </IntList>
</SumComponent>


And the component would have a parameter something like this:

[Parameter]
public List<int> IntList {get; set;}
[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>
<p>The Sum is @(IntList.Sum())</p>
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Blazor/Razor markup formatting?
C#CC# / help
3y ago
❔ Generic component 2 list Blazor server
C#CC# / help
4y ago
✅ Validate input in list in blazor forms
C#CC# / help
3y ago
✅ Can't have interface with abstract static method as parameter in blazor component
C#CC# / help
3y ago