Example #1
0
        static void Main(string[] args)
        {
            HelloService    helloService    = new HelloService();
            ConsumerService consumerService = new ConsumerService(helloService);

            consumerService.Print();

            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            HelloService    helloService    = (HelloService)Activator.CreateInstance(typeof(HelloService));                     //动态创建对象HelloService
            ConsumerService consumerService = (ConsumerService)Activator.CreateInstance(typeof(ConsumerService), helloService); //动态创建对象ConsumerService

            consumerService.Print();

            Console.ReadKey();
        }