![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is @ in front of a string 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. The main advantage of @ symbol is to tell the string constructor to ignore escape characters and line breaks.
Example
using System; using System.IO; namespace DemoApplication{ class Program{ static void Main(string[] args){ Console.WriteLine("test string
test string"); Console.WriteLine(@"test string
test string"); //Both the below statements are same. string jsonString1 = File.ReadAllText(@"D:\Json.json"); string jsonString2 = File.ReadAllText("D:\Json.json"); Console.ReadLine(); } } }
Output
The output of the above code is as follows.
test string test string test string
test string
Advertisements