这句话是什么意思? return @"&quot ;;什么时候使用? [英] what is this statement meaning? return @""; and when it is used?

查看:74
本文介绍了这句话是什么意思? return @"&quot ;;什么时候使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这句话是什么

返回@;

及何时使用?

What is this statement
return @"";
and when it is used?

推荐答案

严格来说,这句话如果正式相当正确。

与此同时,它表明其作者的文盲率很高。

有文化的方式来写这个就是

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
return string.Empty;





在这个例子中使用立即常量,在大多数情况下,是一种不好的风格。即使返回返回@返回string.Empty 是等价的,第一个,特别是第二个变种不是整洁和污染代码。



和'@'只是意味着冗长;它允许使用字符串的多行课程代码并详细处理其他转义的文字(例如\ n),并且表示为双:@这是我的字符串引用里面是相当于这是我的字符串\quote \inside。



顺便说一下,在提出这样的问题之前,你真的需要阅读一些语言手册。



-SA



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


@ Literal [ ^ ]

使用@ 在C#中转义[ ^ ]

S tring literal @ [ ^ ]
@ Literal[^]
Escaping in C# using @[^]
String literal @[^]


请查看此主题



http://stackoverflow.com/questions/3311988/what-is-the-difference-between-a-regular-string-and-a- verbatim-string [ ^ ]


这篇关于这句话是什么意思? return @"&quot ;;什么时候使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆