标题:错误 1 “ConsoleApplication10.Program.Main(string[])”必须声明主体,因 ...
只看楼主
yang9988
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2015-6-23
结帖率:25%
已结贴  问题点数:20 回复次数:4 
错误 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
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
得分:10 
一个程序只能有一个Main方法
2015-06-24 11:28
Maick
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:32
帖 子:251
专家分:1314
注 册:2012-9-21
得分:5 
static void Main(string[] args);
这句肯定错了..方法直接带;号,,,没有{}
2015-06-24 14:12
smart0721
Rank: 6Rank: 6
等 级:侠之大者
威 望:4
帖 子:106
专家分:468
注 册:2012-2-10
得分:5 
嗯,下面的代码应该放在Main方法里面
2015-06-28 12:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-454660-1-1.html




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

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