日期:2014-05-19  浏览次数:20921 次

请教关于接口实现的问题
#region   Using   directives

using   System;
using   System.Collections.Generic;
using   System.Text;

#endregion

namespace   ExtendAndCombineInterface
{
      interface   IStorable
      {
            void   Read(   );
            void   Write(   object   obj   );
            int   Status   {   get;   set;   }

      }

//   here 's   the   new   interface
      interface   ICompressible
      {
            void   Compress(   );
            void   Decompress(   );
      }

//   Extend   the   interface
      interface   ILoggedCompressible   :   ICompressible
      {
            void   LogSavedBytes(   );
      }

//   Combine   Interfaces
      interface   IStorableCompressible   :   IStorable,   ILoggedCompressible
      {
            void   LogOriginalSize(   );
      }

//   yet   another   interface
      interface   IEncryptable
      {
            void   Encrypt(   );
            void   Decrypt(   );
      }

      public   class   Document   :   IStorableCompressible,   IEncryptable
      {

            //   hold   the   data   for   IStorable 's   Status   property
            private   int   status   =   0;

            //   the   document   constructor
            public   Document(   string   s   )
            {
                  Console.WriteLine(   "Creating   document   with:   {0} ",   s   );

            }

            //   implement   IStorable
            public   void   Read(   )
            {
                  Console.WriteLine(
                        "Implementing   the   Read   Method   for   IStorable "   );
            }

            public   void   Write(   object   o   )
            {
                  Console.WriteLine(
      &nbs