CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Trying to Learn

  1. #1
    Join Date
    Mar 2010
    Posts
    0

    Trying to Learn

    I am trying to teach myself about Implementing Inheritance in C# and for the life of me I can't really grasp the conceipt maybe I am over thinking and making it to hard but I dont think thats the case. LOL. I have read all the websites I could think of and I am in need of some input. The example I am working on is posted below. If someone could scribble some code out for me for a example that would be much help. Thanks for your time.



    Add an enumeration to your project called EmployeeType
    1. Add three values called IT, Sales, and Unknown
    ii. Add a new class to your project called Employee
    1. Mark the class abstract
    2. Set the class to inherit from the Person class
    3. Add a virtual property called EmployeeType that will return the EmployeeType.Unknown
    iii. Add a new class to your project called SalesEmployee
    1. Override the EmployeeType property so that it always return EmployeeType.Sales
    2. Add another string property called MiddleName
    3. Add a constructor that accepts a FirstName, MiddleName, LastName, and DateOfBirth
    a. Set the constructor to “chain” to the base class’s constructor
    b. Do not do any validation on the MiddleName parameter
    c. Set the MiddleName property using the corresponding parameter
    4. Override the ToString method to return a value in the format “LastName, FirstName MiddleName” if the MiddleName was provided, otherwise just return the standard “LastName, FirstName” from the Person class’s implementation

    --------------------------------------------------------------------------------

  2. #2
    Join Date
    Dec 2008
    Posts
    144

    Re: Trying to Learn

    There's a book titled Head First C# by Head First Labs- it is, hands down, the best programming book I have every read. I suggest you pick up this book because it will teach you everything you need to know to answer every single question you posted here. I got my from Borders, but Amazon has it for a little bit cheaper.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured