Original link: https://chenyan98.cn/3894.html
1. The introduction of factories The concept of factories: In life, factories produce products. In our software, factories create “objects”. The introduction of the factory: Create the Teacher and Dean object App.config file here: This is the application configuration file. You can save the relevant information of the program configuration to this file. 2. The use of the factory [1] Define the interface [2] The interface implementation In addition to Teacher and Dean, a class to represent OtherTeacher is also written. Like Teacher and Dean, it also inherits from the parent class Person and implements the ITeach interface Two methods in , Exam() and StudyCourse(). [3] Write a factory First, in the App.config file, configure a node to save variable objects […]
This article is reproduced from: https://chenyan98.cn/3894.html
This site is for inclusion only, and the copyright belongs to the original author.