using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace 一个类实现多个接口
{
    public interface Igram//图形接口
    {
        double Area();//接口方法,计算图形面积
        double GramLength();//接口方法,计算图形周长
        int Sides//接口属性,获取图形边长
        {
            get;
        }
    }
    public interface Print//输出结果的接口
    {
        void pritnf();
    }
    public class Square:Igram,Print
    {
        private int sides;
        public int sidelength;
        public Square()
        {
            sides = 4;
        }
        public int Sides
        {
            get
            {
                return sides;
            }
        }
        public double Area()
        {
            return ((double)(sidelength * sidelength));
        }
        public double Gramlength()
        {
            return ((double)(sides * sidelength));
        }
        public void printf()
        {
            Console.WriteLine("计算正方形面积结果如下:");
            Console.WriteLine("边长:{0} 周长:{1} 面积:{2}",this.sidelength,this.Gramlength(),this.Area());
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Square sq = new Square();
            sq.sidelength = 5;
            sq.printf();
            Console.ReadKey();
        }
    }
}

解决方案 »

  1.   

    有错,就是你有两个接口方法没有Implement: GramLength() 和 printf(), 改成下面就好了:
    Namespame用中文还有接口前面最好加个I,这书谁写的,感觉不靠谱using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace 一个类实现多个接口
    {
        public interface Igram//图形接口
        {
            double Area();//接口方法,计算图形面积
            double GramLength();//接口方法,计算图形周长
            int Sides//接口属性,获取图形边长
            {
                get;
            }
        }
        public interface Print//输出结果的接口
        {
            void pritnf();
        }
        public class Square : Igram, Print
        {
            private int sides;
            public int sidelength;
            public Square()
            {
                sides = 4;
            }        public double GramLength()
            {
                throw new NotImplementedException();
            }        public int Sides
            {
                get
                {
                    return sides;
                }
            }
            public double Area()
            {
                return ((double)(sidelength * sidelength));
            }
            public double Gramlength()
            {
                return ((double)(sides * sidelength));
            }
            public void printf()
            {
                Console.WriteLine("计算正方形面积结果如下:");
                Console.WriteLine("边长:{0} 周长:{1} 面积:{2}", this.sidelength, this.Gramlength(), this.Area());
            }        public void pritnf()
            {
                throw new NotImplementedException();
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                Square sq = new Square();
                sq.sidelength = 5;
                sq.printf();
                Console.ReadKey();
            }
        }
    }
      

  2.   

    嗨 ~~下面的函数有什么用?不用怎么会就出错了??
    public double GramLength()
      {
      throw new NotImplementedException();
      }
    public void pritnf()
      {
      throw new NotImplementedException();
      }
      

  3.   

    我写的那两个没什么用,只是实现一下,抛个NotImplementedException异常,里面要具体实现什么功能,你自己填代码就可以了呵呵。