c#取消转义与内插变量标识@与$的应用
////取消转义 //string str = @"a/b/c123"; //bool b=str.StartsWith("a"); //MessageBox.Show(b.ToString()); //str = str.TrimStart('a'); //str = str.TrimEnd('3'); //MessageBox.Show(str); //内插变量 string a = "123"; string str1 = $"abcd'{a}'";
string str2 = string.Format("abc{0}", a); MessageBox.Show(str1);
// 构建SQL查询,检查表是否存在,同时使用取消转义@与内插变量$
string tableName="JLB_Bak";
string sql = $@" SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{tableName.ToUpper()}'";