Megrez7 Megrez7 - 7 months ago 47
C# Question

Code explanation needed

I am familiar. Have a razor c# piece of code. When through pages of documentation but I cannot find out what does this code do? Understand that runs function IsSelected of Html class but what is the meaning of argument passed to it?

<li class="@Html.IsSelected(controller: "Dashboards")>


if I understood correctly you want to under stand what this does

 @Html.IsSelected(controller: "Dashboards")

@ tells razor to output the following to the html code by executing


the parameter is a Named or optional parameter. It is basically saying sets the value of parameter with name "controller" to "Dashboards"

The function's definition might be like

IsSelected(int notUsed = 0, string notUsed2 = null, string controller = "dead beef")

so that you can save yourself some typing instead calling IsSelected(0, null, "Dashboards")