13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

102<strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong>: A Beginner’s <strong>Guide</strong>Ask the ExpertQ: What exactly is meant by inheritance?A: When one class or partial class inherits another class, the inheriting class gets all of thecharacteristics of the class it inherits. That means that the inheriting class, called the child orsubclass of the inherited class, can use all of the methods and properties of the parent class./// Summary description for UseIfaceB/// public class UseIfaceB : IfaceIt{public String Show(){return "Second Implementation";}}You might want to make sure that the files for the interface and the two classes thatimplement the interface are in the App_Code folder before you test your application.When everything is ready, go ahead and test it by selecting the Iface.aspx file in theSolution Explorer and pressing CTRL-F5.Figure 4-9 shows the different results generated by the same interface implemented intwo different classes. The partial class that you’re accustomed to using with <strong>ASP</strong>.<strong>NET</strong> codeis able to instantiate objects based on the interface with no problems. The same is true withlarger structures in C# that use interface.Figure 4-9 <strong>ASP</strong>.<strong>NET</strong> Label displays strings from two different classes implementing a singleinterface.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!