我读了一些有关IOC和Unity的文章,但是感到很困惑:(
所以回到基础知识,有人能告诉我下面的代码是做什么的吗?
private IStudent _student;
public HomeController(IStudent student)
{
_student= student;
}
public interface IStudent
{
// Some method
}
这段代码很基础,我试图从一个外行的角度来理解。它到底做了什么?
我读了一些有关IOC和Unity的文章,但是感到很困惑:(
所以回到基础知识,有人能告诉我下面的代码是做什么的吗?
private IStudent _student;
public HomeController(IStudent student)
{
_student= student;
}
public interface IStudent
{
// Some method
}
public HomeController()
{
private Student _student;
public HomeController()
{
_student = new Student();
}
}
public class Student
{
// Some method
}
public class HomeController
{
private IStudent _student;
public HomeController(IStudent student)
{
_student = student;
}
}
public interface IStudent
{
// Some method
}
public class Student : IStudent
{
// Implementation of some method
}
_container.Register<IStudent, Student>();
_container
是什么? - JAX