Reputation: 3230
When building my Blazor Webassembly solution, the following message occurs for one of my .razor pages :
Member name cannot be the same as their enclosing type
How come ?
Upvotes: 1
Views: 685
Reputation: 3230
It turned out that the name of my razor file equaled the name of one of the methods inside this razor file.
.NET creates classes of each razor page in the \RazorDeclaration\Pages folder of the bin and obj folders. That's why the error occurred : the class was containing a method with the same name.
Change either the file name or the method name and the error should go away.
I think it would be good practice to suffix PageComponent names by "Page" and shared components by "Shared" to avoid these class name collisions.
Upvotes: 3