What is Inheritance in C# .Net ?

Inheritance:

Inheritance is the strong concept of the world of object-oriented programing.

In a Simple word, The mechanism of accessing or extending the behavior or properties of an existing class is known as Inheritance.

For an example, If a class has methods let say Add(int s, int n) and its added two given values. So if we are going to create any class and we want to create an Add function of two variable then why we create it from scratch if this is available in an existing class.

Yes, We can use the Add function of existing class in a new class as below:

public class ExistingClass
{
   public int Add(int s, int n)
   {
      return s+n;
   }
}

and the new class is:

public class NewClass : ExistingClass
{
   base.Add(110,210); // this will call the existing methods

}


Comments

  1. Latest Updates <a href="https://chasannews.com> Latest </a>

    ReplyDelete
  2. Thank you for giving this useful information in this article. It's a fantastic article. I'll be waiting for your next update. I also have some useful information about the Best Custom Software Development Company in India, which I believe will be of great use to you.

    ReplyDelete
  3. Find WordPress Developers in Delhi that are available for hire for your job. Outsource your WordPress jobs to a Freelancer and save.

    ReplyDelete

Post a Comment

Popular posts from this blog

What is unqork?

What is single page Application in web applications

What is SOLID Principle ?