Versions des environnements
An interface says what a class can do, but not how it does it. For example, IDataReader has a Read method that takes no parameters and returns a bool. IDataReader doesn't say how it does the read, but any class that implements IDataReader will have that method. Classes that implement the interface such as SqlDataReader provide the details on how the Read is actually done.
Programming to an interface means that you use the interfaces instead of the classes. Since anything that implements the interface will have the same set of functions and properties, you can do things like substitute the SqlDataReader with an OleDbDataReader with minimal adjustments to your code.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement