运算符"+"不能应用于类型“方法组"和字符串[错误]的操作数 [英] Operator '+' cannot be applied to operands of type 'method group' and string [error]

查看:139
本文介绍了运算符"+"不能应用于类型“方法组"和字符串[错误]的操作数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于此代码,我遇到错误,有任何解决方法吗?

Somehow for this code I''m getting an error, any workaround?

protected void calArticles_SelectionChanged(object sender, EventArgs e)
{
    SqlDataSource1.ConnectionString = 
        System.String.Concat(
        "SELECT [Timestamp], [Subject], [EntryText] FROM [Article] WHERE [Timestamp] = "
        ,calArticles.SelectedDate.ToString + ";");
        
}





错误消息:

错误2运算符"+"不能应用于类型为方法组"和字符串"的操作数c:\ inetpub \ wwwroot \ Jon's Couch \ Articles.aspx.cs 24 14 http://localhost/Jon's Couch/

Error 2 Operator ''+'' cannot be applied to operands of type ''method group'' and ''string'' c:\inetpub\wwwroot\Jon''s Couch\Articles.aspx.cs 24 14 http://localhost/Jon''s Couch/



:confused:



:confused:

推荐答案

ToString是一种方法.与ToString()中一样,使用()调用方法.买一本C#书并阅读.您也不应在表示层中使用字符串混搭SQL,如果您想编写可伸缩且可维护的代码,也不要这样做.
ToString is a method. Use () to call a method, as in ToString(). Buy a C# book and read it. You should also not be string mashing SQL in your presentation layer, not if you want to write scalable and maintainable code.


这篇关于运算符"+"不能应用于类型“方法组"和字符串[错误]的操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆