A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 彭清贵 中级黑马   /  2013-2-2 00:51  /  2944 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 彭清贵 于 2013-2-2 12:17 编辑

今天我自己写一个单线程玩玩;我是这样写的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 单线程
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int sun = 0;
            for (int i = 1; i < 10000000;i++ )
            {
                sun += i;  
            }

            MessageBox.Show(sun.ToString);//提示错误        1        与“System.Windows.Forms.MessageBox.Show(string)”最匹配的重载方法具有一些无效参数;错误        2        参数 1: 无法从“方法组”转换为“string”        




        }
    }
}
我不是已经用了ToString吗,一切都转换为字符串吗,这是为何???
;//提示错误        1        与“System.Windows.Forms.MessageBox.Show(string)”最匹配的重载方法具有一些无效参数;错误        2        参数 1: 无法从“方法组”转换为“string”        



评分

参与人数 1技术分 +1 收起 理由
张文 + 1

查看全部评分

4 个回复

倒序浏览
ToString是方法,请在后面加括号。   MessageBox.Show(sun.ToString());   这样应该就可以了

点评

行了,脑袋一热 忘了我檫  发表于 2013-2-2 11:55

评分

参与人数 1技术分 +1 收起 理由
张文 + 1

查看全部评分

回复 使用道具 举报
应该是sun.ToString(),LZ改一下就行了应该

评分

参与人数 1技术分 +1 收起 理由
张文 + 1

查看全部评分

回复 使用道具 举报
刘明杰 发表于 2013-2-2 08:25
ToString是方法,请在后面加括号。   MessageBox.Show(sun.ToString());   这样应该就可以了 ...

行了,脑袋一热 忘了我檫
回复 使用道具 举报
呵呵,小粗心
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马