Specifying an Interface
Let’s move on from here with our own custom interface, ICarnivore, rather than using an interface that comes
out of the .NET Framework box.
To begin with, an interface is specified using the interface keyword and contains the signatures of the
interface members. For example, if the ICarnivore interface containd one method, CanIEatU, the interface
specification might look like this:
interface ICarnivore {
bool CanIEatU (object obj);
}
This interface specification says that there is one method, of type bool, that takes a parameter of type
object. It’s worth emphasizing that the interface specification contains not a jot or iota of implementation
code. It simply says: You have committd to implement me and therefore you must have a method named CanIEatU
that takes an object argument and returns a bool.
|
|
Search Engine Optimization
 
Syndication Viewer
Our Web host:
IX WebHosting
|