473,491 Members | 3,350 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

multiple inheritance in C#

83 New Member
Hii all ,

I know that there is no support for multiple inheritance in .NET.

but if i declare a class like

Expand|Select|Wrap|Line Numbers
  1. public class myclass
  2. {
  3.  
  4. }
  5.  
by default it gets inherited from system.Object.

and if i inherit the class from class baseclass like below

Expand|Select|Wrap|Line Numbers
  1. public class myclass:baseclass
  2. {
  3.  
  4. }
  5.  
it is equals to
Expand|Select|Wrap|Line Numbers
  1. public class myclass:System.Object,baseclass
  2. {
  3.  
  4. }
  5.  
it means it supports multiple inheritance.Am i correct?

Thanks & Regards,
Tirumala Reddy.B
Oct 5 '10 #1
4 1958
hype261
207 New Member
It depends upon how you think about it. Yes in your example myClass is derived from 2 classes, but you can't have..

Expand|Select|Wrap|Line Numbers
  1. public class myClass: baseClass, baseClass2
  2. {
  3. }
This is why people say C# doesn't support multiple inheritance. On the other hand C# does allow you to inherit from multiple classes assuming that 1 is only a real class and the others are interfaces.

Expand|Select|Wrap|Line Numbers
  1. public class myClass : baseClass, IanInterface
  2. {
  3. }
It is just easier to say that C# doesn't support multiple inheritance than to say C# supports multiple inheritance except that...
Oct 5 '10 #2
btreddy
83 New Member
Thanks for the reply

But sorry i'm not clear yet.

what is the difference between the following classes;
Expand|Select|Wrap|Line Numbers
  1. public class mycalss{}
  2.  
Expand|Select|Wrap|Line Numbers
  1. public class myclass:System.Object{}
  2.  
in both the declarations i'm able to access all the 4 methods that are there in system.object.

someone can help me in explaining what actually happening inside.

Thanks in advance

Rgds,
Tiru.
Oct 5 '10 #3
GaryTexmo
1,501 Recognized Expert Top Contributor
All objects in C# inherit from object by default, it's just a thing. I think Java does this too. So I believe those are the same.
Oct 5 '10 #4
btreddy
83 New Member
Thanks Gary for your reply.
Oct 5 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4318
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
5
2161
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
30
2672
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
20
10026
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
22
23312
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
47
3587
by: Mark | last post by:
why doesn't .NET support multiple inheritance? I think it's so silly! Cheers, Mark
60
4862
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
7
3711
by: Adam Nielsen | last post by:
Hi everyone, I'm having some trouble getting the correct chain of constructors to be called when creating an object at the bottom of a hierarchy. Have a look at the code below - the inheritance...
21
2451
by: raylopez99 | last post by:
Well, contrary to the implication in my 2000 textbook on C# (public beta version), C# does allow multiple inheritance, so long as it's serially chained as follows: class derived02 : derived01 {...
2
2527
by: Paul McGuire | last post by:
On May 25, 8:37 am, Michael Hines <michael.hi...@yale.eduwrote: Here's a more general version of your testing code, to detect *any* diamond multiple inheritance (using your sample classes). --...
0
6980
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.