Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

That the razor syntax is neat, there's little arguing about. But i can't seem to find it anywhere...
What are the razor reserved words?
@using
@inherits
@functions
@section
Do you know any other?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
383 views
Welcome To Ask or Share your Answers For Others

1 Answer

Here's a list of Razor reserved keywords (Note: This applies to cshtml, vbhtml follows VB's rules):

Razor-specific keywords

  • inherits
  • functions
  • section
  • helper
  • model (only in MVC projects)

You can escape these using @(inherits)

Language-specific Razor keywords

These are C# keywords that are understood by Razor

  • if
  • do
  • try
  • for
  • foreach
  • while
  • switch
  • lock
  • using
  • case
  • default

You can escape them using @(@lock) (first @ is used to escape the Razor parser and the second @ is used to escape the C# parser)

Reserved keywords

These are not reserved in RC but will be for RTM. Update: These will have no functionality for RTM. They are simply reserved for future use.

  • namespace
  • class
  • layout

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...