Method return an interface

前端 未结 6 1008
青春惊慌失措
青春惊慌失措 2021-02-02 01:18

Hi All,

I\'m thinking in this line of code

IDataReader myReader = questDatabase.ExecuteReader(getQuest);

I\'m using DA

6条回答
  •  不思量自难忘°
    2021-02-02 01:50

    The method will return an object, which is an instance of a class, and that type of class will support IDataReader.

    The point is, the type of the object isn't important, just the fact that the class implements the interface.

    If you're driving a car, you don't need to know if it's a ford, or a toyota, you drive the car the same way.

    The driving interface is the same, once the car supports the interface, you can drive it.

    Ditto with the IDataReader, once the class that is returned supports the interface, you can use it.

提交回复
热议问题