Multiple base classes in .NET

This is a discussion on Multiple base classes in .NET within the Framework and Interface Programming forums in category; I just read a blurb in MSDN under the C++ "ref" keyword which states that: "Under the CLR object model, only public single inheritance is supported". Does this mean that no .NET class can ever support multiple inheritance. In C++ for instance I noticed that the compiler flags an error if you use the "ref" keyword on a class with multiple base classes. This supports the above quote. However, under the "CodeClass2.Bases" property (part the VS extensibility model), it states that: "Bases are super types of CodeElements. For Visual Basic and Visual C# there is always only one element in ...

Go Back   Application Development Forum > Framework and Interface Programming

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-13-2007, 07:49 PM
Larry Smith
Guest
 
Default Multiple base classes in .NET

I just read a blurb in MSDN under the C++ "ref" keyword which states that:

"Under the CLR object model, only public single inheritance is supported".

Does this mean that no .NET class can ever support multiple inheritance. In
C++ for instance I noticed that the compiler flags an error if you use the
"ref" keyword on a class with multiple base classes. This supports the above
quote. However, under the "CodeClass2.Bases" property (part the VS
extensibility model), it states that:

"Bases are super types of CodeElements. For Visual Basic and Visual C#
there is always only one element in the collection except when the code type
is a CodeInterface".

This is true of course since these languages only support single (class)
inheritance. However, it should be true for all .NET classes based on the
first quote above. My issue is therefore this. I want to retrieve the base
class of an arbitrary class in an arbitrary code file by invoking
"CodeClass2.Bases.Item(1)". This works in my testing but will it always work
for all languages in theory, assuming the class I'm targetting is always a
..NET class of course. Thanks in advance.


Reply With Quote
  #2  
Old 07-13-2007, 07:59 PM
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
 
Default Re: Multiple base classes in .NET

Larry Smith wrote:
> I just read a blurb in MSDN under the C++ "ref" keyword which states that:
>
> "Under the CLR object model, only public single inheritance is supported".
>
> Does this mean that no .NET class can ever support multiple inheritance.


I belive so.

> This is true of course since these languages only support single (class)
> inheritance. However, it should be true for all .NET classes based on the
> first quote above. My issue is therefore this. I want to retrieve the base
> class of an arbitrary class in an arbitrary code file by invoking
> "CodeClass2.Bases.Item(1)". This works in my testing but will it always work
> for all languages in theory, assuming the class I'm targetting is always a
> .NET class of course. Thanks in advance.


If is is arbitrary code, then I belive that you should be using
Type BaseType.

And it is obvious that it will only return one type.

Arne

Reply With Quote
  #3  
Old 07-13-2007, 07:59 PM
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
 
Default Re: Multiple base classes in .NET

Larry Smith wrote:
> I just read a blurb in MSDN under the C++ "ref" keyword which states that:
>
> "Under the CLR object model, only public single inheritance is supported".
>
> Does this mean that no .NET class can ever support multiple inheritance.


I belive so.

> This is true of course since these languages only support single (class)
> inheritance. However, it should be true for all .NET classes based on the
> first quote above. My issue is therefore this. I want to retrieve the base
> class of an arbitrary class in an arbitrary code file by invoking
> "CodeClass2.Bases.Item(1)". This works in my testing but will it always work
> for all languages in theory, assuming the class I'm targetting is always a
> .NET class of course. Thanks in advance.


If is is arbitrary code, then I belive that you should be using
Type BaseType.

And it is obvious that it will only return one type.

Arne

Reply With Quote
  #4  
Old 07-13-2007, 08:04 PM
Jesse Houwing
Guest
 
Default Re: Multiple base classes in .NET

* Larry Smith wrote, On 14-7-2007 1:49:
> I just read a blurb in MSDN under the C++ "ref" keyword which states that:
>
> "Under the CLR object model, only public single inheritance is supported".
>
> Does this mean that no .NET class can ever support multiple inheritance. In
> C++ for instance I noticed that the compiler flags an error if you use the
> "ref" keyword on a class with multiple base classes. This supports the above
> quote. However, under the "CodeClass2.Bases" property (part the VS
> extensibility model), it states that:
>
> "Bases are super types of CodeElements. For Visual Basic and Visual C#
> there is always only one element in the collection except when the code type
> is a CodeInterface".
>
> This is true of course since these languages only support single (class)
> inheritance. However, it should be true for all .NET classes based on the
> first quote above. My issue is therefore this. I want to retrieve the base
> class of an arbitrary class in an arbitrary code file by invoking
> "CodeClass2.Bases.Item(1)". This works in my testing but will it always work
> for all languages in theory, assuming the class I'm targetting is always a
> .NET class of course. Thanks in advance.


The Visual Studio Extensibility model also supports non-CLR languages
(native C++ for example), so it has support for multiple inheritance.

The .NET types do not support multiple inheritance as you've already
found out. I've read a couple of rumors that multiple inheritance will
probably find its way back into the CLR in a future version...

Jesse
Reply With Quote
  #5  
Old 07-13-2007, 08:04 PM
Jesse Houwing
Guest
 
Default Re: Multiple base classes in .NET

* Larry Smith wrote, On 14-7-2007 1:49:
> I just read a blurb in MSDN under the C++ "ref" keyword which states that:
>
> "Under the CLR object model, only public single inheritance is supported".
>
> Does this mean that no .NET class can ever support multiple inheritance. In
> C++ for instance I noticed that the compiler flags an error if you use the
> "ref" keyword on a class with multiple base classes. This supports the above
> quote. However, under the "CodeClass2.Bases" property (part the VS
> extensibility model), it states that:
>
> "Bases are super types of CodeElements. For Visual Basic and Visual C#
> there is always only one element in the collection except when the code type
> is a CodeInterface".
>
> This is true of course since these languages only support single (class)
> inheritance. However, it should be true for all .NET classes based on the
> first quote above. My issue is therefore this. I want to retrieve the base
> class of an arbitrary class in an arbitrary code file by invoking
> "CodeClass2.Bases.Item(1)". This works in my testing but will it always work
> for all languages in theory, assuming the class I'm targetting is always a
> .NET class of course. Thanks in advance.


The Visual Studio Extensibility model also supports non-CLR languages
(native C++ for example), so it has support for multiple inheritance.

The .NET types do not support multiple inheritance as you've already
found out. I've read a couple of rumors that multiple inheritance will
probably find its way back into the CLR in a future version...

Jesse
Reply With Quote
  #6  
Old 07-13-2007, 08:20 PM
Larry Smith
Guest
 
Default Re: Multiple base classes in .NET

>> I just read a blurb in MSDN under the C++ "ref" keyword which states
>> that:
>>
>> "Under the CLR object model, only public single inheritance is
>> supported".
>>
>> Does this mean that no .NET class can ever support multiple inheritance.

>
> I belive so.
>
>> This is true of course since these languages only support single (class)
>> inheritance. However, it should be true for all .NET classes based on the
>> first quote above. My issue is therefore this. I want to retrieve the
>> base class of an arbitrary class in an arbitrary code file by invoking
>> "CodeClass2.Bases.Item(1)". This works in my testing but will it always
>> work for all languages in theory, assuming the class I'm targetting is
>> always a .NET class of course. Thanks in advance.

>
> If is is arbitrary code, then I belive that you should be using
> Type BaseType.


Thanks for the tip. It might prove useful later but for the moment I might
not be able to retrieve the "Type" (since my app processes raw source files
before they may have even been compiled yet).


Reply With Quote
  #7  
Old 07-13-2007, 08:20 PM
Larry Smith
Guest
 
Default Re: Multiple base classes in .NET

>> I just read a blurb in MSDN under the C++ "ref" keyword which states
>> that:
>>
>> "Under the CLR object model, only public single inheritance is
>> supported".
>>
>> Does this mean that no .NET class can ever support multiple inheritance.

>
> I belive so.
>
>> This is true of course since these languages only support single (class)
>> inheritance. However, it should be true for all .NET classes based on the
>> first quote above. My issue is therefore this. I want to retrieve the
>> base class of an arbitrary class in an arbitrary code file by invoking
>> "CodeClass2.Bases.Item(1)". This works in my testing but will it always
>> work for all languages in theory, assuming the class I'm targetting is
>> always a .NET class of course. Thanks in advance.

>
> If is is arbitrary code, then I belive that you should be using
> Type BaseType.


Thanks for the tip. It might prove useful later but for the moment I might
not be able to retrieve the "Type" (since my app processes raw source files
before they may have even been compiled yet).


Reply With Quote
  #8  
Old 07-13-2007, 08:37 PM
Larry Smith
Guest
 
Default Re: Multiple base classes in .NET

> The Visual Studio Extensibility model also supports non-CLR languages
> (native C++ for example), so it has support for multiple inheritance.
>
> The .NET types do not support multiple inheritance as you've already found
> out. I've read a couple of rumors that multiple inheritance will probably
> find its way back into the CLR in a future version...


Thanks for the clarification (appreciated). As for the rumour, I'm not sure
how they'll tackle that given that there already seem to be some built-in
assumptions based on single-inheritance. They could change this of course
but it might cause a lot of problems. Anyway, thanks again.


Reply With Quote
  #9  
Old 07-13-2007, 08:37 PM
Larry Smith
Guest
 
Default Re: Multiple base classes in .NET

> The Visual Studio Extensibility model also supports non-CLR languages
> (native C++ for example), so it has support for multiple inheritance.
>
> The .NET types do not support multiple inheritance as you've already found
> out. I've read a couple of rumors that multiple inheritance will probably
> find its way back into the CLR in a future version...


Thanks for the clarification (appreciated). As for the rumour, I'm not sure
how they'll tackle that given that there already seem to be some built-in
assumptions based on single-inheritance. They could change this of course
but it might cause a lot of problems. Anyway, thanks again.


Reply With Quote
  #10  
Old 07-13-2007, 09:05 PM
Mark Rae [MVP]
Guest
 
Default Re: Multiple base classes in .NET

"Larry Smith" <no_spam@_nospam.com> wrote in message
news:eZO4O8axHHA.1208@TK2MSFTNGP05.phx.gbl...

> Thanks for the clarification (appreciated). As for the rumour, I'm not
> sure how they'll tackle that given that there already seem to be some
> built-in assumptions based on single-inheritance. They could change this
> of course but it might cause a lot of problems. Anyway, thanks again.


I'd be surprised if we ever see multiple inheritance in C#...

http://blogs.msdn.com/csharpfaq/arch.../07/85562.aspx
http://www.google.co.uk/search?hl=en...eritance&meta=


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:31 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.