gpt4 book ai didi

c# - C#中 "@"是什么意思

转载 作者:行者123 更新时间:2023-12-03 18:18:18 25 4
gpt4 key购买 nike

新学员的快速问题,
C# 代码中“@”的含义是什么?

例子:

ClientDataSource.Where = @"it.ClientID==1";
cont.Notes = @"";
Response.Redirect(@"~/Default.aspx");

谢谢!

最佳答案

那是一个 verbatim string literal .

MSDN describes it as such :

Use verbatim strings for convenience and better readability when the string text contains backslash characters, for example in file paths. Because verbatim strings preserve new line characters as part of the string text, they can be used to initialize multiline strings. Use double quotation marks to embed a quotation mark inside a verbatim string.


@也可用于创建与保留字匹配的标识符: 2.4.2 Identifiers

例如:
var class = "Reading"; // compiler error
var @class = "Math"; // works

关于c# - C#中 "@"是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5931865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com