為什么controller中只能使用接口類型,使用接口的實現(xiàn)類會報錯
private MockIStudent student;
??????? public HomeController(MockIStudent _student)
??????? {
??????????? student = _student;
??????? }
private MockIStudent student;
??????? public HomeController(MockIStudent _student)
??????? {
??????????? student = _student;
??????? }
舉報
2020-08-12
因為你添加的依賴注入是接口而不是實現(xiàn)類,如果你寫成下面這種就可以
直接注入實現(xiàn)類