Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
What is this statement
return @"";
and when it is used?
Posted
Comments
BillWoodruff 10-Feb-14 2:24am    
Where did you see this statement: is it in your own code ?
vrushali arbune 11-Feb-14 0:03am    
no i am referring a project there i saw this statement
vrushali arbune 11-Feb-14 0:04am    
public override string GetLogicalDeleteColumnName()
{
return @"";
}

Strictly speaking, this statement if formally quite correct.
At the same time, it indicates considerable illiteracy of its author.
A literate way to write this would be
C#
return string.Empty;


Using immediate constants like in this example, in most cases, is a sign of bad style. Even though return "", return @"" and return string.Empty are equivalent, the first and especially second variants are not neat and contaminate code.

And '@' just means verbosity; it allows to use a multiline course code of the string and treat otherwise escaped literals (such as "\n") verbosely, and " is expressed as double ": @"this is my string with ""quote"" inside" is equivalent to "this is my string with \"quote\" inside".

By the way, before asking such questions, you really need to read some language manual.

—SA
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900