作者deuter (Harold)
看板C_Sharp
标题Re: [问题] '@' 这个东西是做啥用的??
时间Sun Oct 8 14:48:33 2006
两种用途, 第一种比较常见, 放在字串前, 例如
stting s = @"c:\temp\test.txt";
方便阅读, 这样就不用写成 "c:\\temp\\test.txt"
另一种用途是可以让你用保留字来当作变数名称, 例如你可以写
int @class = 0;
string @if = "abc";
class, if 都是保留字, 但是加了@就可以当成变数名字
不过显然这不是很好的写法
※ 引述《dm33 ()》之铭言:
: public string getDirToSave(){
: return @textBox3.Text;
: }
: 看到别人source code里有这个 @
: 是拿来做什麽用的?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 67.188.209.156
1F:推 dm33:恩 了解 感谢! 10/09 12:55