Chapter 3

 < Day Day Up > 


A sealed class cannot be inherited. A sealed class is used primarily when the class contains static members. Note that a struct is implicitly sealed.


A class can inherit from one class explicitly and inherits from System.Object implicitly. It can inherit from any number of interfaces.


  1. ShowName is static and cannot be referenced from a class instance.

  2.  ShowName.ShowMe("My Name is Ishmael"); 


An abstract class may contain both abstract and non-abstract methods.


new is used to replace (not override) an inherited method with one of the same name.


(a) x=60 y=40. x is passed by reference; y by value.


Include a method that performs the same operation as the operator overloading.


A class cannot be instantiated if it is abstract or if it has a private constructor.


Example event handler:

 private void PrintSale(object sender, SaleEvArgs e) {    decimal prc=  (decimal)e.saleprice;    DateTime dt = (DateTime);    int itemNum = (int)e.itemnum;    // Now print the values } 


(a) Compilation error indicating that keyword new is required on Child.amethod(int, string) because it hides the inherited method. If new is used, the code prints "Base Constructor".

     < Day Day Up > 

    Core C# and  .NET
    Core C# and .NET
    ISBN: 131472275
    EAN: N/A
    Year: 2005
    Pages: 219 © 2008-2017.
    If you may any questions please contact us: