To clarify even further, within your Accept method, if you refere to
aCustomer (which you declared as an ITicket), you can "see" (at compile
time) only the interface methods. However, at run time, you passed a
Customer (called myCustomer) to the method. You can do that because the
Customer class implements ITicket. So, at run time, your Accept
method's aCustomer parameter is pointing to a Customer object.
The compiler will allow Accept to look at _only_ the interface methods
defined in ITicket, not the instance methods of the Customer class,
becuase all you've told it is that aCustomer implements ITicket. The
compiler doesn't know that at run time this will be a Customer object
and so will have all of Customer's instance methods.
You can use Reflection to test what kind of object it really is, and
cast it back to a Customer if you like:
public void Accept(aCustomer ITicket)
{
...
Customer cust = aCustomer as Customer;
if (cust != null)
{
... now can call object's Customer instance methods via "cust"
variable ...
}
}
By casting the aCustomer (an ITicket) back to a Customer variable
(cust), you can then get at its instance methods. However, you need to
do the cast, in effect telling the compiler, "Yes, I know that this is
a Customer object. Work with it as though it were a Customer."
It's very important here to keep in mind the distinction between what
is known at compile time and what is known at run time. The compiler is
really relying on you, the programmer, to tell it what's what. It has
_no idea_ what kind of object you're going to pass to Accept at run
time. The compiler knows only what you've told it: that whatever object
it is, at run time, it implements the ITicket interface. It's only at
run time that an actual object (which must be an instance of some
class) is passed to Accept. Only at run time do you know that this
object is really a Customer, or a SalesOrder, or a Widget, all of which
implement the ITicket interface.
Certainly you can write tests that will check (at run time) what kind
of thing aCustomer refers to:
Customer cust = aCustomer as Customer;
or
if (aCustomer is Customer) { ... }
but the compiler doesn't automagically "know" what you've passed to the
method, beyond what you've explicitly declared.