What does @ character d mean in C#
C# string string can be preceded by @ (called "word-by-word string") to treat escaped characters (\) as normal characters, such as:
string str = @"C:\Windows";
Equivalent to:
string str = "C:\\Windows";
@ You can have any newline in a string, and the newline and indented spaces are calculated within the length of the string.
string str = @"<script type=""text/javascript""> <!-- --> </script>";
3 functions of @ in C#
1. Ignore escape characters
For example:
string fileName = "D:\\Text File\\";
After using @
string fileName = @"D:\Text File\";
2. Let the string cross line
For example:
string strSQL = "SELECT * FROM AS e" + " INNER JOIN AS c" + " ON = " + " ORDER BY ";
After using @
string strSQL = @"SELECT * FROM AS e INNER JOIN AS c ON = ORDER BY ";
3. Usage in identifiers
C# does not allow keywords to be used as identifiers (class name, variable name, method name, tablespace name, etc.), but if @ is added, it will be fine.
For example:
public static void @static(int @int) { if (@int > 0) { ("Positive Integer"); } else if (@int == 0) { ("Zero"); } else { ("Negative Integer"); } }
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.