為什么controller中只能使用接口類型,使用接口的實(shí)現(xiàn)類會(huì)報(bào)錯(cuò)
private MockIStudent student;
??????? public HomeController(MockIStudent _student)
??????? {
??????????? student = _student;
??????? }
private MockIStudent student;
??????? public HomeController(MockIStudent _student)
??????? {
??????????? student = _student;
??????? }
舉報(bào)
2020-08-12
因?yàn)槟闾砑拥囊蕾囎⑷胧墙涌诙皇菍?shí)現(xiàn)類,如果你寫成下面這種就可以
直接注入實(shí)現(xiàn)類