Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Possible Duplicate:
What's the use/meaning of the @ character in variable names 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?

like image 334
Greg Avatar asked Jan 09 '09 20:01

Greg


People also ask

What does * Before a variable mean in C?

In computer programming, a dereference operator, also known as an indirection operator, operates on a pointer variable. It returns the location value, or l-value in memory pointed to by the variable's value. In the C programming language, the deference operator is denoted with an asterisk (*).

What does & before variable mean in C?

The & means "Don't take the variable, take the place in memory where this variable is stored." It's a little complicated, but it's necessary so that C can change the value of the variable.

What is the use of @IN front of a variable?

Putting @ in front of a string tells the compuler not to process escape sequences found within the string.

What is $@ in C#?

It marks the string as a verbatim string literal. In C#, a verbatim string is created using a special symbol @. @ is known as a verbatim identifier. If a string contains @ as a prefix followed by double quotes, then compiler identifies that string as a verbatim string and compile that string.


1 Answers

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

int @class = 15; 

The above works, when the below wouldn't:

int class = 15; 
like image 168
Michael Meadows Avatar answered Sep 21 '22 08:09

Michael Meadows