Possible Duplicate:
when to use @ in c# ?
F.e. string sqlSelect = @"SELECT * FROM Sales".
%= Modulus AND assignment operator. It takes modulus using two operands and assigns the result to the left operand. C %= A is equivalent to C = C % A.
The only use of '#' in C is to introduce a “pre-processor directive”. C assumes that there is a step that happens before the normal compilation step that processes any lines that start with a '#' symbol. Hence, we have things like: #include “somefile.h”
%d is a format specifier, used in C Language. Now a format specifier is indicated by a % (percentage symbol) before the letter describing it. In simple words, a format specifier tells us the type of data to store and print. Now, %d represents the signed decimal integer.
It means interpret the following string as literal. Meaning, the \
in the string will actually be a "\"
in the output, rather than having to put "\\"
to mean the literal character
Before string it allows different string formating rules. You can't use backslash to specify special symbols and "" (double quotes become quotes). I find this format very useful for regular expressions
Example
Console.WriteLine(@"\n""\/a"); // outputs \n"\/a
Console.WriteLine("\\n\"\"\\/a"); // outputs \n"\/a
You might also seen @ symbol before variable. In such case it allows using special C# keywords as variables.
Example:
var @switch = 1;
var @if = "test";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With