| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2423 人关注过本帖
标题:错误 1 “ConsoleApplication10.Program.Main(string[])”必须声明主体,因 ...
取消只看楼主 加入收藏
yang9988
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2015-6-23
结帖率:25%
收藏
已结贴  问题点数:20 回复次数:1 
错误 1 “ConsoleApplication10.Program.Main(string[])”必须声明主体,因为它未标记为 abstract、extern
static void Main(string[] args);

        struct APoint//描述点数据的结构
        {
            public int X;//x坐标
            public int Y;//y坐标
            public APoint(int point_X, int point_Y)//带参数的构造函数
            {
                this.X = point_X;
                this.Y = point_Y;
            }

            public void Move(int offset_X, int offset_Y)//移动点坐标的办法
            {
                X += offset_X;
                Y += offset_Y;
            }
            public override string ToString()//重载tostring方法
            {
                return X.ToString() + "," + Y.ToString();


                Console.WriteLine("使用ArrayList");
                ArrayList pnts = new ArrayList(3);
                for (int i = 0; i < 3; i++)
                {
                    pnts.Add(new APoint(100, 100));//ArrayList赋值
                }
                for (int i = 0; i < 3; i++)
                {//ArrayList中的元素执行Move方法 伴随着装箱和取消装箱,原数组元素的值并未改变
                    ((APoint)pnts[i]).Move(400, 400);
                }
                for (int i = 0; i < 3; i++)
                { Console.WriteLine("第" + i.ToString() + "点的坐标是(" + pnts[i].ToString() + ")"); }
                Console.WriteLine("使用数组");
                APoint[] points = new APoint[3];
                for (int i = 0; i < 3; i++)
                { points[i] = new APoint(100, 100); }//数组赋值
                Console.WriteLine("使用foreach循环");
                foreach (APoint point in points)
                {//数组中的元素执行Move方法,在foreach循环中伴随装箱过程,原数组元素并未改变
                    point.Move(400, 400);
                }
                for (int i = 0; i < 3; i++)
                { Console.WriteLine("第" + i.ToString() + "点的坐标是(" + points[i].ToString() + ")"); }
                Console.WriteLine("使用for循环");
                for (int i = 0; i < 3; i++)
                {//直接操作数组中的元素,没有装箱和取箱的过程,原数组的元素发生改变
                    points[i].Move(400, 400);
                }
                for (int i = 0; i < 3; i++)
                {
                    Console.WriteLine("第" + i.ToString() + "点的坐标是(" + points[i].ToString() + ")");
                }
                Console.ReadLine();
搜索更多相关主题的帖子: abstract public 
2015-06-23 18:03
yang9988
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2015-6-23
收藏
得分:0 
求大神呀 坐等
2015-06-23 18:03
快速回复:错误 1 “ConsoleApplication10.Program.Main(string[])”必须声明主体 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034795 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved