How can some features be supported by C# and not .NET?

F

Fister

I'm reading Professional C# (Wrox) and stumbled across:

"Some features are supported by.NET but not by C#, and you might be surprised
to learn that some features of the C# language are not supported by .NET
(for example, some instances of operator overloading)!"

How can some features be supported by C# and not .NET? Are there other features
than operator overloading and could someone please supply an example?

/ Fister
 
M

Marc Gravell

As a suggestion - the string concatenation operator is provided by the
C# compiler, not the String class; this allows "a" + "b" + "c" + "d"
etc to be a single call (to String.Concat), not successive add
operations.

This might also refer to CLS compliance?

Marc
 
M

Marc Gravell

Of course, re my last post, you could argue that this *is* supported,
precisely by calling string.Concat()...

Marc
 
N

Nicholas Paldino [.NET/C# MVP]

Fister,

One can interpret the first statement:

Some features are supported by.NET but not by C#

To mean that features that you see in the language are not necessarily
implemented in the language, but rather, in the framework. In this case, I
would say the type aliases, like int, string, etc, etc. The functionality
is provided by the framework.

As for the second statement, regarding operator overloading, .NET
doesn't support it outright. The language picks it up through specially
named static method signatures. VB now honors this convention as well, but
the framework doesn't enforce it.

I do think that the author could have phrased the second part a little
better.
 
J

Jon Skeet [C# MVP]

Marc Gravell said:
Of course, re my last post, you could argue that this *is* supported,
precisely by calling string.Concat()...

It's just not supported as an addition operator on the string type.

Some of the nullable conversions may be similar - not sure.
 
F

Fred Mellender

They might be referring to features built into the CLR, and not exposed by
the C# language, but which might be used/exposed in some other .NET
language.

I'm not expert enough to give an example, but it *might* be that the CLR has
direct support for pointers and associated logic in order to implement C++,
but such features are not used/exposed/"supported" by C#.
 
M

Marc Gravell

features built into the CLR, and not exposed by
the C# language

That would be the other way around to the OP;
the classic example of CLR and not C# woud be
return-value overloading, which almost no
language supports, but which is legal CLR.

Marc
 
J

Jon Skeet [C# MVP]

Fred Mellender said:
They might be referring to features built into the CLR, and not exposed by
the C# language, but which might be used/exposed in some other .NET
language.

I'm not expert enough to give an example, but it *might* be that the CLR has
direct support for pointers and associated logic in order to implement C++,
but such features are not used/exposed/"supported" by C#.

Another example is covariance and contravariance in generics - the CLR
has support for this (for interfaces) but C# doesn't expose it.

For more on this topic, see
http://blogs.msdn.com/rmbyers/archive/2005/02/16/375079.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top