DZone
My favourite feature with .Net and C# is that it’s a static programming language. This is also the largest problem I have with .Net 5 – As in, its blessing also becomes its curse. Simply because sometime I need a bit more “dynamic nature” than that which .Net provides out of the box. However, .Net 5 has a lot of interesting features, allowing you to circumvent this, opening it up for a more “dynamic nature”. Let me illustrate with an example C# HTTP API controller.
<div class="codeMirror-code–wrapper" data-code="[Route("magic")]
public class EndpointController : ControllerBase
{
[HttpGet]
[Route("{*url}")]
public async Task Get(string url)
{
/* Do interesting stuff with URL here */
}
}” data-lang=”text/x-csharp”>
x
[Route("magic")]
public class EndpointController : ControllerBase
{
[HttpGet]
[Route("{*url}")]
public async Task<ActionResult> Get(string url)
{
/* Do interesting stuff with URL here */
}
}