读书人

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

发布时间: 2013-11-11 14:02:17 作者: rapoo

非静态字段引用
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);
你既然用了常量 就是不能修改 还在后面加变量就没有意义了

读书人网 >C#

热点推荐