I am working on a project that declares html attributes as @class = "className" or @id = "ID" however for this form control it does not happen:
@Html.CheckBoxFor(Model => Model.IsEBSCreated, new { disabled = "disabled" })
Questions:
disabled
not have an @
symbol before it?@
symbol not always required?checked
require an @
symbol?Thank you
@
prefix on an identifier in C# allows language keywords to be used as identifiers, aka verbatim identifier.@
with C#'s contextual keywords like from
and where
- only C#'s reserved keywords.Why does the HTML attribute
disabled
not have an@
symbol before it?
Because disabled
is not a C# language keyword.
Is the
@
symbol not always required?
Only when you're using a C# language keyword as an identifier.
Does the HTML attribute
checked
require an@
symbol?
Yes, because checked
(and unchecked
) are C# language keywords.
For example:
public interface @interface
{
string? @string { get; }
}
public class @class : @interface
{
private static readonly string? @null = null;
string? @interface.@string => @null;
}
Feel free to use the above code in a team project if you happen to dislike a particular member of your team.