using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace jicheng
{
    class Furniture
    {
        string colour;
        float height;
        float length;
        public Furniture(string a, float b, float c)
        {
            colour = a  ;
            height = b ;
            length = c ;
        }
        public string display1()
        {
            Console.WriteLine("颜色:{0}", colour );
        }
        public float display2()
        {
            Console.WriteLine("高度:{0}  长度:{1}",height,length  );
        }
    }
    class Bookshelf : Furniture
    {
        int shelf;
        public Bookshelf():base("红色",3.5f ,5.5f)
        {
            shelf = 5;
        }
        public int display3()
        {
            Console.WriteLine("层数:{0}", shelf);
        }
    }
    class Chair : Furniture
    {
        int leg;
        public Chair():base("黄色",1.0f,0.5f)
        {
            leg = 3;
        }
        public int display4()
        {
            Console.WriteLine("腿数:{0}", leg);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Bookshelf obj = new Bookshelf();
            obj.display1();
            obj.display2();
            obj.display3();
            Chair my = new Chair();
            my.display1();
            my.display2();
            my.display4();
            Console.ReadLine();        }
      
    }
}

解决方案 »

  1.   

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; namespace jicheng 

        class Furniture 
        { 
            string colour; 
            float height; 
            float length; 
            public Furniture(string a, float b, float c) 
            { 
                colour = a  ; 
                height = b ; 
                length = c ; 
            } 
            public string display1() 
            { 
                Console.WriteLine("颜色:{0}", colour ); 
            } 
            
            public float display2() 
            { 
                Console.WriteLine("高度:{0}  长度:{1}",height,length  ); 
            } 
        } 
        class Bookshelf : Furniture 
        { 
            int shelf; 
            public Bookshelf():base("红色",3.5f ,5.5f) 
            { 
                shelf = 5; 
            } 
            public int display3() 
            { 
                Console.WriteLine("层数:{0}", shelf); 
            } 
        } 
        class Chair : Furniture 
        { 
            int leg; 
            public Chair():base("黄色",1.0f,0.5f) 
            { 
                leg = 3; 
            } 
            public int display4() 
            { 
                Console.WriteLine("腿数:{0}", leg); 
            } 
        } 
        class Program 
        { 
            static void Main(string[] args) 
            { 
                Bookshelf obj = new Bookshelf(); 
                obj.display1(); 
                obj.display2(); 
                obj.display3(); 
                Chair my = new Chair(); 
                my.display1(); 
                my.display2(); 
                my.display4(); 
                Console.ReadLine();         } 
          
        } 
    } 红色标注部分的代码都有问题,你的确没有返回值!你既然申明了类型就要返回return,否则请换用void表示无返回
     
      将帖子提前   放进我的网摘   推荐给好友 我要提问 帖子加分 结帖去... 管理菜单 页面风格切换标准风格老版本论坛 
      

  2.   

    你的display()方法返回类型改为void就可以了,否则是必须都有返回值的,Console.WriteLine只是输出到控制台,不给方法提供返回值。