Part 8: C# Tutorial – Introduction to Inheritance




In this article we will cover following points

1. Inheritance
2. Use of Inheritance
3. Points to remember about inheritance
4. Derived Class Communication with Base Class
5. Methods in Base class & Derived classes

Inheritance

Characteristics  or Pillars of Object Oriented Programming

  1. Inheritance
  2. Encapsulation
  3. Polymorphism

1. Inheritance enables to create new classes that reuse, extend and modify the behaviour that
is defined in another classes.

2. The class whose members are inherited is called the base class, and the class that inherits
those members is called the derived class.

3. A derived class can have only one direct base class.

class1
Use of Inheritance

1. Ideally a derived class is a specialization of the base class, which means the derived class
extends the functionality of the base class.
class2

Points to remember

1. C# supports only single class inheritance.

2. But C# supports multiple interface inheritance.

3. Base class or parent class constructor executes before derived or child class constructor.

4. Derived class implicitly gains all the members of the base class, except for its constructors
and destructors.

5. Derived class has access to the public, protected, internal, and protected internal members
of base class. Derived class inherits the private members of a base class but it cannot access
those members.

6. Base classes are automatically instantiated before derived classes.

Derived Class Communication with Base Class

1. Using the base keyword, you can access any of a base class public or protected class
members.

2. Alternatively Base class members can be accessed through an explicit cast.

Methods in Base class & Derived classes

1. If base class declares a method as virtual, derived class can override the method with its own
implementation.

2. Derived class can hide base class members by declaring members with the same name and
signature. The new keyword can be used to hide the base class members.



148 thoughts on “Part 8: C# Tutorial – Introduction to Inheritance

    1. surendra Post author

      thanks very much for your feedback. appreciate it.

      I am trying to update the content of the blog on regular basis.

  1. have a peek at this site

    certainly like your web-site but you need to check the spelling on quite a few of your posts. A number of them are rife with spelling issues and I find it very troublesome to tell the truth nevertheless I’ll surely come back again.

  2. her comment is here

    What i do not realize is in reality how you are no longer really a lot more well-favored than you might be now. You are very intelligent. You already know thus significantly in the case of this topic, produced me for my part imagine it from so many various angles. Its like women and men don’t seem to be involved except it’s something to accomplish with Girl gaga! Your own stuffs outstanding. Always care for it up!

  3. click here to read

    Thanx for the effort, keep up the good work Great work, I am going to start a small Blog Engine course work using your site I hope you enjoy blogging with the popular BlogEngine.net.Thethoughts you express are really awesome. Hope you will right some more posts.

  4. this

    I simply want to mention I am newbie to blogging and site-building and definitely loved this web page. Very likely I’m likely to bookmark your blog . You surely come with great writings. With thanks for sharing with us your blog site.

  5. westerly life

    “Hiya there, just turned out to be conscious of your blog through Google, and realized that it is pretty interesting. I’ll be grateful for if you decide to carry on these.”

  6. ProudReview

    “We’re a group of volunteers and starting a new scheme in our community. Your website offered us with valuable info to work on. You’ve done a formidable job and our whole community will be thankful to you.”

  7. Tercio Borlenghi Junior

    “Hi there! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyhow, I’m definitely delighted I found it and I’ll be book-marking and checking back often!”

  8. Wedding Dresses

    “I was suggested this blog by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my difficulty. You are incredible! Thanks!”

  9. grandstream 2160

    “I’ve been browsing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the web will be much more useful than ever before.”

  10. brandflap

    “”I think this is one of the most significant info for me. And i am glad reading your article. But wanna remark on few general things, The site style is ideal, the articles is really nice D. Good job, cheers””

  11. Lernpakete

    “F*ckin’ tremendous things here. I am very satisfied to peer your article. Thank you so much and i’m taking a look ahead to touch you. Will you kindly drop me a mail?”

  12. Safety posters

    “I would like to thank you for the efforts you’ve put in writing this website. I am hoping the same high-grade website post from you in the upcoming as well. In fact your creative writing skills has inspired me to get my own site now. Actually the blogging is spreading its wings fast. Your write up is a good example of it.”

  13. Custom Banner

    “hello!,I like your writing so much! share we communicate more about your article on AOL? I need an expert on this area to solve my problem. Maybe that’s you! Looking forward to see you.”

  14. shopebe.com

    “I’ve been absent for a while, but now I remember why I used to love this website. Thank you, I will try and check back more often. How frequently you update your website?”

  15. products sourcing

    “Somebody essentially help to make seriously articles I would state. This is the first time I frequented your website page and thus far? I amazed with the research you made to make this particular publish incredible. Great job!”

  16. car covers

    “”Excellent read, I just passed this onto a friend who was doing some research on that. And he actually bought me lunch since I found it for him smile So let me rephrase that Thank you for lunch!””

  17. Ac ductless company

    “Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher! Come on over and visit my web site. Thanks =)”

  18. natural hair shirts

    “Good post. I learn one thing more difficult on different blogs everyday. It would always be stimulating to learn content from other writers and apply slightly something from their store. I’d prefer to use some with the content material on my weblog whether you don’t mind. Natually I’ll provide you with a hyperlink on your internet blog. Thanks for sharing.”

  19. macbook leather sleeve

    “That is the proper blog for anyone who desires to seek out out about this topic. You realize a lot its almost arduous to argue with you (not that I actually would want…HaHa). You positively put a new spin on a topic thats been written about for years. Nice stuff, simply nice!”

  20. shopify no sales

    “I like what you guys are up also. Such intelligent work and reporting! Keep up the excellent works guys I’ve incorporated you guys to my blogroll. I think it will improve the value of my website :)”

  21. alarmas para ropa

    “You could definitely see your skills in the work you write. The world hopes for even more passionate writers like you who aren’t afraid to say how they believe. Always go after your heart.”

  22. Tax Law

    “Howdy! Would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would really appreciate your content. Please let me know. Cheers”

  23. ct best breakfast mystic

    “I am curious to find out what blog platform you have been utilizing? I’m having some minor security problems with my latest website and I’d like to find something more safe. Do you have any recommendations?”

  24. Btw Berekenen

    “I was recommended this web site by my cousin. I’m not sure whether this post is written by him as no one else know such detailed about my difficulty. You are incredible! Thanks!”

  25. 24 Stunden Pflege

    “Sweet blog! I found it while surfing around on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks”

  26. Revitol eczema cream

    “Great paintings! This is the kind of information that should be shared around the web. Disgrace on the seek engines for no longer positioning this post upper! Come on over and visit my website. Thanks =)”

  27. Soccer Cleats 2017

    “I’m not sure why but this web site is loading extremely slow for me. Is anyone else having this issue or is it a problem on my end? I’ll check back later and see if the problem still exists.”

  28. CAMPING COTS

    “Wow! This blog looks exactly like my old one! It’s on a entirely different topic but it has pretty much the same layout and design. Outstanding choice of colors!”

  29. under armour outlet australia

    “I just like the valuable info you supply on your articles. I’ll bookmark your weblog and check once more here frequently. I am relatively sure I’ll be informed many new stuff proper right here! Best of luck for the following!”

  30. Guter Gaming TV

    “Wow! This can be one particular of the most beneficial blogs We’ve ever arrive across on this subject. Basically Excellent. I am also a specialist in this topic so I can understand your hard work.”

  31. best business books uk

    “Heya! I just wanted to ask if you ever have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no data backup. Do you have any solutions to prevent hackers?”

  32. best business books uk

    “I precisely desired to thank you so much once more. I do not know what I would have carried out in the absence of these methods contributed by you concerning this area of interest. It absolutely was a real depressing concern in my circumstances, however , being able to see a specialized tactic you solved the issue took me to jump for joy. Now i’m grateful for this help and in addition trust you recognize what a powerful job you’re putting in educating the others all through a blog. Most likely you haven’t met all of us.”

  33. public relations books

    “I’m not sure exactly why but this site is loading very slow for me. Is anyone else having this problem or is it a issue on my end? I’ll check back later on and see if the problem still exists.”

  34. buy kona

    “”I believe this is one of the such a lot important info for me. And i’m happy studying your article. But wanna commentary on some basic issues, The web site taste is perfect, the articles is truly excellent D. Good task, cheers””

  35. African elephants

    “Link exchange is nothing else but it is just placing the other person’s website link on your page at appropriate place and other person will also do same in favor of you.”

  36. Botswana

    “Excellent post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit more. Thank you!”

  37. Varicose Veins

    “I was just seeking this info for a while. After 6 hours of continuous Googleing, finally I got it in your website. I wonder what is the lack of Google strategy that do not rank this type of informative sites in top of the list. Usually the top websites are full of garbage.”

  38. i thought about this

    I just want to tell you that I am just new to weblog and certainly savored you’re blog site. Very likely I’m planning to bookmark your website . You definitely have really good writings. Thanks a bunch for sharing your blog.

Leave a Reply

Your email address will not be published. Required fields are marked *