zoukankan      html  css  js  c++  java
  • 接口2

    /*
     * 由SharpDevelop创建。
     * 用户: jinweijie
     * 日期: 2015/10/28
     * 时间: 15:25
     * 
     * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
     */
    using System;

    namespace Interface
    {
        interface IStorable
        {
            void Read();
            void Write();
            int Status{get;set;}
        }
        interface ITalk
        {
            void Read();
            void Talk();
        }
        public class Document:IStorable,ITalk
        {
            
            int status;
            
            public virtual void  Read()
            {
                Console.WriteLine("Read data from database");
            }
            
            public void Write()
            {
                Console.WriteLine("Write data into database");
            }
            
            public int Status {
                get {
                    return status;
                }
                set {
                    status = value;
                }
            }
            
    //        public void Talk()
    //        {
    //            Console.WriteLine("Talk for ITalk");
    //        }
            
            
            void ITalk.Talk()
            {
                Console.WriteLine("Talk for ITalk");
            }
            void ITalk.Read()
            {
                Console.WriteLine("Read for ITalk");
            }
        }
        class Note:Document
        {
            public new void Write()
            {
                Console.WriteLine("Write for Note");
            }
            public override void Read()
            {
                Console.WriteLine("Read for Note...");
            }
        }
        
        class Program
        {
            public static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
                
                // TODO: Implement Functionality Here
    //            IStorable doc = new Note();
    //            doc.Status = 10;
    //            doc.Write();
    //            doc.Read();
    //            Note nt = doc as Note;
    //            if(nt != null)
    //            {
    //                nt.Write();
    //            }
    //            
                Document doc = new Document();
                ITalk  idoc = doc;
                idoc.Read();
                
                Console.Write("Press any key to continue . . . ");
                Console.ReadKey(true);
            }
        }
    }

  • 相关阅读:
    Sql学习第二天——SQL DML与CTE解释
    Sql学习第一天——SQL UNION 和 UNION ALL 操作符(1)
    Sql学习第一天——SQL 练习题(3)
    Sql学习第一天——SQL 将变量定义为Table类型(2)
    C#性能优化实践(摘抄)
    SQL数据纵横列查询
    「SHOI2006」有色图
    SP419/422 TRANSP(2) Transposing is Fun
    ARC084F XorShift
    洛谷 P4708 画画(无标号欧拉子图计数)
  • 原文地址:https://www.cnblogs.com/jinweijie0527/p/4917836.html
Copyright © 2011-2022 走看看