C# Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 2322 Page Views: 

How would you implement inheritance using VB.NET/C#?



Posted By: Avi Date: 5 February 2010 01:49:08 PM
 Answer:

When we set out to implement a class using inheritance, we must first start with an existing class from which we will derive our new subclass. This existing class, or base class, may be part of the .NET system class library framework, it may be part of some other application or .NET assembly, or we may create it as part of our existing application.

Once we have a base class, we can then implement one or more subclasses based on that base class. Each of our subclasses will automatically have all of the methods, properties, and events of that base class? Including the implementation behind each method, property, and event. Our subclass can add new methods, properties, and events of its own - extending the original interface with new functionality. Additionally, a subclass can replace the methods and properties of the base class with its own new implementation - effectively overriding the original behavior and replacing it with new behaviors.

Essentially inheritance is a way of merging functionality from an existing class into our new subclass.

Inheritance also defines rules for how these methods, properties, and events can be merged.


Posted By: eTechPlanet


Date: 5 February 2010 01:49:08 PM

By using inherits keyword v can implement inheritance and only single level, multiple level, and hybrid inheritance is supported in vb.net.


Posted By: Johndecruse


Date: 17 February 2010 02:23:56 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image Fmuagc
Related Questions
C# : Write the syntax of calling an overloaded constructor within a constructor?

Write the syntax of calling an overloaded constructor within a constructor?

Syntax:- class sum1 { sum1(int count) { } } class sum0 : sum1 { sum0() : sum1(2) // calling bas....
Category: C# Date: 10/1/2010 11:34:31 AM
C# : Write the difference between TypeOf and GetType?

Write the difference between TypeOf and GetType?

Both of them produce the same information. The difference lies that from where the information is go....
Category: C# Date: 10/1/2010 11:33:31 AM
C# : What is Obsolete in C#? How can one make a method obsolete?

What is Obsolete in C#? How can one make a method obsolete?

Obsolete attributemarks the program entity as the one that is not recommended to be used further. Us....
Category: C# Date: 10/1/2010 11:32:31 AM
C# : How are strings compared in C#?

How are strings compared in C#?

Generally , whenever the strings are to be compared using "==" or "!=" operators....
Category: C# Date: 10/1/2010 11:31:31 AM
C# : I want to declare a variable naming checked, but it gives an error Why?

I want to declare a variable naming checked, but it gives an error Why?

This is because checked is a keyword in C# and keywords can't be used as a variable name.
Category: C# Date: 10/1/2010 11:30:31 AM