Live Chat Icon For mobile
Live Chat Icon

‘ChildContent’: member names cannot be the same as their enclosing type. What does this mean?

Platform: Blazor| Category: Error handling

The parameter name and component (file) name should not be the same. They must be unique. For example, in the below code snippet the component name is ChildComponent so we cannot have a parameter with the same name it will not compile


<h2>Parent Title is: @Title</h2>
<button @onclick="UpdateParentsTitle">Update Title</button>
@code {
    //the parameter name cannot be ChildComponent since component name is ChildComponent
    [Parameter] public string Title { get; set; }

    [Parameter] public EventCallback<string> TitleChanged { get; set; }

    private async Task UpdateParentsTitle()
        Title = "Hello, From Child Component!";
        await TitleChanged.InvokeAsync(Title);

Share with