Can someone explain inheritance in c sharp?
Can someone explain inheritance in c sharp?
When a new class needs to use components of an existing class, then instead of recreating(typing again) those variables again in new class, the new class can use the code/variables directly from the existing class, this basically is inheritance.
The central benefit of inheritance is the re-use of code which saves time and lightens the workload.
The class that is derived is called the derived/child/subclass and the main class is called the base/parent/superclass. All the non private variables in the main class will available in the derived class.
A simple web search for "C# inheritance" turns up dozens of links to good information. Here's the first result: Inheritance (C# Programming Guide), complete with examples and everything!
If you understand what you're doing, you're not learning anything.