Use of IsAssignableFrom and “is” keyword in C#

后端 未结 4 2051
谎友^
谎友^ 2020-12-03 02:41

While trying to learn Unity, I keep seeing the following code for overriding GetControllerInstance in MVC:

if(!typeof(IController).IsAssignableF         


        
4条回答
  •  自闭症患者
    2020-12-03 03:09

    typeof(IController).IsAssignableFrom(controllerType) tests a Type against the interface. The is operator tests an instance against the interface.

提交回复
热议问题