0

In the following HtmlHelper:

@Html.TextBoxFor(model=>model.Username, new { id = "username", @class = "textbox"})

Some attributes like class have an @ before it while others don't. what does at sign mean there?

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171

2 Answers2

2

Some attributes like class have an @ before it while others don't

that is because the C# language has a keyword class already. Only to negate its meaning you use @ . The same thing goes for the C# keyword type and html input element attribute type

Rajshekar Reddy
  • 18,647
  • 3
  • 40
  • 59
2

class is a reserved word in c#, so it cannot be used as a variable name, for making it valid variable name we need to add @ sign in start of it, it can be used for making a reserved word a valid variable whenever needed.

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160