| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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. |
|
#2
| |||
| |||
| 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 |
|
#3
| |||
| |||
| 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 |
|
#4
| |||
| |||
| * 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 |
|
#5
| |||
| |||
| * 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 |
|
#6
| |||
| |||
| >> 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). |
|
#7
| |||
| |||
| >> 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). |
|
#8
| |||
| |||
| > 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. |
|
#9
| |||
| |||
| > 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. |
|
#10
| |||
| |||
| "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 |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.