ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Which type of inheritance is not supported by classes in C#??

also explain reason.if u can.

user-image
تم إضافة السؤال من قبل Mukhtar Ahmad
تاريخ النشر: 2014/08/19
Ahmad Anbari
من قبل Ahmad Anbari , Software System Engineer , Continental Jet Services FZCO

Multiple inheritance is not supported in C# and Java.

You can implement more than one Interface, which somehow a substitute for multiple inheritance supported in languages like C++.

In C++ you can create a class which inherit from more than one class. Some people think this could lead to complexity. Look at the diagram below. 

                                             class A

                                                /\\

                                              /    \\

                                 class B       class C  

                                              \\   /

                                               \\/

                                          class D

 

If someone writes a class (class D) that inherits from two classes (class B and class C), and these two classes have same property name, which they inherit from a super class (class A), like  public string Name. In this case class D will have a dupplicated property. This is also known as Diamond Scenario and can be solved by using virtual inheritance.

 

 

Muhammed Effat Ahmed Afifi
من قبل Muhammed Effat Ahmed Afifi , Project Leader [Microsoft Business Unit] , Wipro Arabia Limited

Dear as mentioned in many location over the internet that c# doesn't support multiple inheritance due to that multiple inheritance will lead by default to multiple implementation which will increase code architect complexity and definitely will increase the conflict probability.

viswanath Selvaraj
من قبل viswanath Selvaraj , Software Developer , Geewiz Technology

Multiple Inheritance will not  be supported

Abdul rahman Velliparambil Muhiyidheen
من قبل Abdul rahman Velliparambil Muhiyidheen , ERP Consultant and Team Lead , Al-Jazeera Factory for Paints

Multiple inheritance is not supported in C# because they reasoned that adding MI added too much complexity to the languages while providing too little benefit.

Murtuza Kanpurwala
من قبل Murtuza Kanpurwala , Senior UI Developer

Supported : Single , Multilevel , Hiearchical , Hybrid

 

Due to the complexity of a code multiple inheritance is not been supported in C# or in DOT.NET but DOT.NET or C# supports multiple interfaces.

Multiple inheritance is not supported in c# classes.interfaces can support these multiple inhertance.

Md Mazedur Rahman
من قبل Md Mazedur Rahman , Asst. Manager-HRIS , Base Textiles Limited

  1. Different languages actually have different expectations for how MI works. For example, how conflicts are resolved and whether duplicate bases are merged or redundant. Before we can implement MI in the CLR, we have to do a survey of all the languages, figure out the common concepts, and decide how to express them in a language-neutral manner. We would also have to decide whether MI belongs in the CLS and what this would mean for languages that don't want this concept (presumably VB.NET, for example). Of course, that's the business we are in as a common language runtime, but we haven't got around to doing it for MI yet.

  2. The number of places where MI is truly appropriate is actually quite small. In many cases, multiple interface inheritance can get the job done instead. In other cases, you may be able to use encapsulation and delegation. If we were to add a slightly different construct, like mixins, would that actually be more powerful?

  3. Multiple implementation inheritance injects a lot of complexity into the implementation. This complexity impacts casting, layout, dispatch, field access, serialization, identity comparisons, verifiability, reflection, generics, and probably lots of other places.

Rizwan Shah
من قبل Rizwan Shah , Project Manager , COMSATS IIT

Multiple Inheritance. As it will lead to code complexity etc ..

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟