首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

错误提示:不包含适合入口点的静态'main'方法?请高手帮小弟我改一下这程序

2011-12-10 
错误提示:不包含适合入口点的静态main方法?请高手帮我改一下这程序classPhoto{string_titlepublicPhoto

错误提示:不包含适合入口点的静态'main'方法?请高手帮我改一下这程序
class   Photo
        {
                string   _title;
                public   Photo(string   title)//构造方式,并初始化照片名
                {
                        this._title   =   title;
                }
                public   string   Title//照片名的属性
                {
                        get
                        {
                                return   _title;
                        }
                }
        }

        class   Album
        {
                Photo[]   photos;
                public   Album(int   capacity)//构造方式,并指定相册的大小
                {
                        photos=new   Photo[capacity];
                }
                public   Photo   this[int   index]
                {
                        get
                        {
                                if   (index   <   0   ||   index   > =   photos.Length)
                                {
                                        Console.WriteLine( "索引无效 ");
                                        return   null;
                                }
                                return   photos[index];
                        }
                        set
                        {
                                if   (index   <   0   ||   index   > =   photos.Length)
                                {


                                        Console.WriteLine( "索引无效 ");
                                        return;
                                }
                                photos[index]   =   value;
                        }
                }
                public   Photo   this[string   title]
                {
                        get
                        {
                                foreach   (Photo   p   in   photos)//遍历数组中的所有照片
                                {
                                        if   (p.Title   ==   title)
                                        {
                                                return   p;
                                        }                                        
                                }
                                Console.WriteLine( "未找到 ");
                                return   null;
                        }
                }
        }

        class   TestIndexr
        {
                static   void   main(string[]   args)
                {
                        Album   friends   =   new   Album(3);

                        Photo   first   =   new   Photo( "Jenn ");
                        Photo   second   =   new   Photo( "Smith ");
                        Photo   third   =   new   Photo( "Mark ");


                        friends[0]   =   first;
                        friends[1]   =   second;
                        friends[2]   =   third;

                        Photo   obj1Photo   =   friends[2];
                        Console.WriteLine(obj1Photo.Title);

                        Photo   obj2Photo   =   friends[ "Jenn "];
                        Console.WriteLine(obj2Photo.Title);

                }
        }

[解决办法]
static void Main()

热点排行