Getting Started with Adobe After Effects - Part 6: Motion Blur
This module helps you to share, discuss and learn interview questions and answers of different technologies

C# - Why Multiple inheritance is not supported

Dec 26 2011 11:21PM by Ramireddy   

Question

Recently in one of interviews, i faced this question "Why multiple inheritance is not supported"?

Answer

If a Type inherits from multiple Types, then it is called multiple inheritance. In C#, a class can't inherit from multiple classes. There are few reasons behind not implementing multiple inheritance in C#.

  1. Multiple inheritance is very difficult to implement. Assume a class “A” inherited from both B and C; Both B and C classes implements same method; When an object of class “A” is created and when the method is called, which method supposed to be executed. Though this is not so impossible to implement (C++ implemented with “Virtual” keyword), this will cause various side effects in areas like casting. As this usage of this feature is very little, C# team decided not to support this feature.
  2. Another reason behind this is for CLS compliance. Under .NET Framework, there are around 70 languages. As this feature is difficult to implement, many languages might implement differently and some languages might not implement at all. If this feature is supported by .NET framework, there are more chances it will affect those languages. By considering this .NET framework didn’t support this.

C# provides another alternative for multiple inheritances. A class or interface can inherit from multiple interfaces. We can create multiple interfaces and make the class to inherit from those classes.

Read More..   [32134 clicks]

Published under: C# Interview Questions and Answers ·  ·  ·  · 


Ramireddy
2 · 41% · 12972
0
Liked
 
0
Asked



Submit

Your Comment


Sign Up or Login to post a comment.

"C# - Why Multiple inheritance is not supported" rated 5 out of 5 by 2 readers
C# - Why Multiple inheritance is not supported , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]