[EDIT by guadrex to add the metadata. @Seabizkit, please use the This Page feedback button+form at the bottom of any topic to open an issue. It will automatically add the metadata and ping the author.]
overloads do not work
simple example
@{
void RenderName(string name)
{
<p>Name: <strong>@name</strong></p>
}
void RenderName(int intValue)
{
<p>Name: <strong>@intValue</strong></p>
}
}
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@NTaylorMullen Is this supported? It's not addressed in the Razor syntax topic.
@NTaylorMullen Is this supported? It's not addressed in the Razor syntax topic.
Overloads should work. @Seabizkit what issue are you seeing with them?
@NTaylorMullen
that complains... as is, does not compile....."name already exist... compile error" but what is interesting unless i missed something... but below works... surely they should both work.
@functions
{
void RenderName(string name)
{
<p>Name: <strong>@name</strong></p>
}
void RenderName(int intValue)
{
<p>Name: <strong>@intValue</strong></p>
}
}
key word functions, makes it work... how odd
key word functions, makes it work... how odd
Ahh, interesting what you're seeing then is a C# restriction.When you say @functions {...} what you're saying is add the following to my class body where @{} entails add the following to a method in my class body (a local function). Therefore since C# doesn't support overloaded local functions you can't utilize them in @{}.
I can reproduce in a simple console app:

@guardrex is there a "by design" equivalent label?
No, but we don't cover it in the Razor syntax topic. Would you like it covered there?
If we close as by-design, it can be labelled with the product-question label .............
I guess this makes sense _not_ to cover it. The error message is fairly clear in the sense that 'you can't do this.'
Most helpful comment
If we close as by-design, it can be labelled with the
product-questionlabel .............I guess this makes sense _not_ to cover it. The error message is fairly clear in the sense that 'you can't do this.'