Search code examples
c#variablesnamingspecificationsreserved-words

What does the @ symbol before a variable name mean in C#?


I understand that the @ symbol can be used before a string literal to change how the compiler parses the string. But what does it mean when a variable name is prefixed with the @ symbol?


Solution

  • The @ symbol allows you to use reserved word. For example:

    int @class = 15;
    

    The above works, when the below wouldn't:

    int class = 15;