int a = -777777777;
Console.WriteLine("Please type a number between 1 to 10..." + a);
Console.WriteLine($"Please type a number between 1 to 10...{a}");
之前连接字符串的时候都是用+来,有了$符号以后,可以直接在双引号中间直接放一个花括号,然后在花括号中放入变量了。
在写sql语句的时候,再也不用担心字符连接的问题了。
另外一个@,有2个作用:
1.忽略转义字符;
2.让字符串跨行,没有加@,换行的时候需要好多引号和加号了,有了@可以直接换行了。
string cmd1 = "select * from MockRoom " +
"where Name='房间名称'";
string cmd2 = @"select * from MockRoom
where Name='房间名称'";