Razor语法中'@'的术语是什么?

3 asp.net-mvc razor

我读过的材料通常使用"在这里使用@字符表示开头......"这样的短语,但我想知道这个字符叫什么.同事建议使用"令牌"这个词,但我不认为这是正确的.

hai*_*770 5

很好地查看源代码,Razor团队似乎将其称为Transition Symbol.

SyntaxConstants中:

namespace System.Web.Razor.Parser
{
    public static class SyntaxConstants
    {
        public static readonly char TransitionCharacter = '@';
        public static readonly string TransitionString = "@";
    }
}
Run Code Online (Sandbox Code Playgroud)

同样在HtmlSymbolType.Transition中:

namespace System.Web.Razor.Tokenizer.Symbols
{
    public enum HtmlSymbolType
    {
        ...
        Transition, // @
    }
} 
Run Code Online (Sandbox Code Playgroud)

尽管如此,我怀疑你可以正式命名为"Transition",它似乎更像是解析器的内部术语来表示上下文切换(例如从HTML到C#,反之亦然).