首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

非静态字段引用,该怎么处理

2013-11-11 
非静态字段引用private const string sql_select2 select [year] as 年,[month] as 月,[money_plan] as

非静态字段引用
private const string sql_select2 = "select [year] as 年,[month] as 月,[money_plan] as 计划金额 from month_money where year='" + b1 + "'and month='" + b2 + "'";

走过路过的同学们帮忙看看,这代码要怎么改。
[解决办法]
const是常量  个人感觉你这样写的结果貌似没多大用
你可以试试private const string sql_select2 = "select [year] as 年,[month] as 月,[money_plan] as 计划金额 from month_money where year='{0}'and month='{1}'";
用的时候string.format(sql_select2,b1,b2);
你既然用了常量 就是不能修改 还在后面加变量就没有意义了

热点排行