एक Class को एक से अधिक Class या Interface से Derive किया जा सकता है, जिसका अर्थ है कि यह Multiple Base Classes या Interfaces से Data और Functions Inherit कर सकती है।
उदाहरण के लिए, Vehicle Base Class निम्न Derived Classes के साथ:
Truck Bus Motobike
Derived Class, Base Class के Member Variables और Member Methods को Inherit करती है।
इसी तरह, Shape Class के लिए Derived Class Rectangle हो सकती है जैसा कि निम्न Example में दिखाया गया है।
Example
using System; namespace Program { class Shape { public void setWidth(int w) { width = w; } public void setHeight(int h) { height = h; } protected int width; protected int height; } // Derived Class class Rectangle: Shape { public int getArea() { return (width * height); } } class Demo { static void Main(string[] args) { Rectangle Rect = new Rectangle(); Rect.setWidth(5); Rect.setHeight(7); // Object का Area Print करें। Console.WriteLine("Total area: {0}", Rect.getArea()); Console.ReadKey(); } } }Output
Total area: 35