Demystifying The Code

ASP.NET AJAX Client Library Question And Answer Series – Question 1

I recently received an email from a person who had viewed my ASP.NET AJAX Client Library series.  The email contained 22 questions centered around our AJAX Client Libraries.  As these were excellent questions, most requiring more than one line responses, I decided to do a blog entry for 1 or 2 questions daily until I have completed the list.  If you would like me to answer your questions, please add them to the list by emailing me.  So today, I am going to start the process:

Question 1: Can interfaces inherit from other interfaces?

Answer:

As you may know, ASP.NET AJAX provides the capability to create interfaces, an OO feature not available in JavaScript.  In order to create / register a namespace in ASP.NET AJAX, you simply follow the JavasSript prototype pattern to create your constructor function and prototype.  Then call registerInterface on your new interface.  It is that simple.  Here is an example:

Interface

So, now that we have illustrated to you that interfaces exist and how to create a simple interface, lets get back to the question.  In C#, interfaces can inherit from other interfaces.  The implementing class must adhere to the contacts of the complete transitive closure of the explicit base interfaces.  Is this possible in ASP.NET AJAX Client Libraries?  The answer is no.  We can validate this by looking at the registerInterface signature here:

Signature

As you can see, there is no means to pass a base interface type.  However, you are free to implement as many interfaces as you would like within a class.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Demystifying The Code