首页 > 其他 > 详细

框架设计(一)

时间:2015-08-12 00:54:50      阅读:149      评论:0      收藏:0      [点我收藏+]

定义接口:

public interface ITest
    {
        double GetPrice();

    }

某个类实现接口:

public class Test1 : ITest
    {
        public double GetPrice()
        {
            return 0.32;
        }
    }

定义壳子实体类:

public class Test
    {
        private ITest Itest;

        public Test(ITest itest)
        {
            this.Itest = itest;
        }

        public double GetPrice()
        {
            return this.Itest.GetPrice();
        }
    }

调用:

class Program
    {
        static void Main(string[] args)
        {
            Test test = new Test(new Test1());
            var returnVal = test.GetPrice();
            Console.Write(returnVal);
            Console.Read();
        }
    }

 

框架设计(一)

原文:http://www.cnblogs.com/webczw/p/4722566.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!