1. Are there some features of C# language not supported by .NET?

Skill/Topic: Advanced
A) Yes
B) No
Explanation: For example some instances of operator overloading!

Showing Answers 1 - 8 of 8 Answers

ebuah

  • Dec 31st, 2005
 

how can the answer to this question be yes. Multiple inheritance is not a feature of c#. c# does NOT support multiple inheritance or mixed inheritance so the answer to this question is no. All features of c# are supported by .net.

s

  • Feb 15th, 2006
 

"One important thing to make clear is that C# is a language in its own right. Although it is designed to generate code that targets the .NET environment,it is not itself part of .NET. There are some features that are supported by .NET only and not C# and you might be surprised to learn that there are actually features of C# not supported by .NET(for example, some instances of operator overloading)!!"

---page4,professional C#,3rd edition.

  Was this answer useful?  Yes

Sreerenj

  • Mar 28th, 2006
 

The author is asking whether there is any feature in C# that is not supported by .NET. So the answer is Yes. All the explanations are right, but the answer should be Yes(i suppose).

  Was this answer useful?  Yes

With respect to multiple inheritance, I would have to say that the answer is
"mostly" that C# does not support multiple inheritance.


The "mostly" part does not take into account the .NET 3.5 and C# 3.0
extension method concepts. Using extension methods, you can actually extend
interfaces! That's right... you can INHERIT actual implementation from an
interface!


For example:


public interface IContainsNoMethods
{
}
public class MyClass : IContainsNoMethods
{
}


MyClass "implements" the IContainsNoMethods interface. It hasn't actually
implemented anything though since IContainsNoMethods forces no contract onto
MyClass. Now add this to this bit of code:


static public class ExtendsIContainsNoMethods
{
static public void Foo(this IContainsNoMethods i)
{
Console.WriteLine("Welcome to multiple-inheritance... sort of.");
}
}


Now, you can instantiate an instance of MyClass and call THROUGH
IContainsNoMethods... to the Foo method. Like so:


MyClass myClass = new MyClass();
myClass.Foo();


It will print out "Welcome to multiple-inheritance... sort of.".


Now, that's snazzy isn't it! You can now "implement" as may interfaces as you
want... and if extension methods exist for those interfaces... you'll have
pseudo-inheritance from multiple sources. So, in a very limited way, we have
multiple inheritance in the latest version of C#.


Enjoy!


- Wil

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions