Which .net features exactly are exposed through the language?

I

igivanovg

Example: msdn says explicitly that enumerable/enumerators are exposed
via foreach. It says so a thousand times everywhere. Ok.

Now we have the Convert class and and its counterparts in the form of
conversions expressed through special C# syntax. Nowhere could I find
that the compiler translates language constructs into calls to
Convert.ConvertTo(xxx) though I suspect it does. But then maybe it
doesn't and there are subtle differences.

Question: Is there a place in msdn which I am missing that documents
every .net feature that in some form or other is expressed via a
specific C# construct, keyword, etc.

Thanks!
 
J

Jon Skeet [C# MVP]

Example: msdn says explicitly that enumerable/enumerators are exposed
via foreach. It says so a thousand times everywhere. Ok.

Now we have the Convert class and and its counterparts in the form of
conversions expressed through special C# syntax. Nowhere could I find
that the compiler translates language constructs into calls to
Convert.ConvertTo(xxx) though I suspect it does. But then maybe it
doesn't and there are subtle differences.

No, it doesn't.
Question: Is there a place in msdn which I am missing that documents
every .net feature that in some form or other is expressed via a
specific C# construct, keyword, etc.

Well, the C# language specification is the best place to go for that.
Download it from http://msdn2.microsoft.com/en-us/vcsharp/aa336809.aspx


However, off the top of my head:

foreach statement - IEnumerable/IEnumerable<T>/IDisposable
using statement - IDisposable
lambda expressions - Expression tree types
iterator blocks - IEnumerable/IEnumerable<T>/IDisposable

Query expressions use Enumerable/Queryable etc - but the compiler
itself doesn't know about them.
 
M

Marc Gravell

For all of this, the language spec mainly (ECMA 334 for C# 2; I don't
know the number for C# 3 [is there one yet?]). Unfortunately it is
rather dry reading. I could start listing, but I'd surely miss a good
pile of them...
says explicitly that enumerable/enumerators are exposed via foreach

While it is true that enumerable/enumerables are usable via foreach,
*strictly* speaking you need neither IEnumerable[<T>] nor
IEnumerator[ said:
Nowhere could I find
that the compiler translates language constructs into calls to
Convert.ConvertTo(xxx) though I suspect it does.

I suspect that it uses the implicit/explicit conversion operators
defined for the types in question; see 8.2.2 of ECMA 334

Marc
 
I

igivanovg

For all of this, the language spec mainly (ECMA 334 for C# 2; I don't
know the number for C# 3 [is there one yet?]). Unfortunately it is
rather dry reading. I could start listing, but I'd surely miss a good
pile of them...
Thanks.
Nowhere could I find
that the compiler translates language constructs into calls to
Convert.ConvertTo(xxx) though I suspect it does.

I suspect that it uses the implicit/explicit conversion operators
defined for the types in question; see 8.2.2 of ECMA 334

Well, I searched the Standard, there is not a single mention of the
System.Convert class, which puzzles me. If Convert is not used
implicitly by the language, then its relation to C# conversions is
unclear and it's unclear what one should use Convert for, at least in
C#. If it is implicitly used, then I guess we have a documentation bug
in the Standard or in the MS implementation of C#.

(While I am interested in the Convert case, I mentioned is just as an
example)
 
J

Jon Skeet [C# MVP]

Well, I searched the Standard, there is not a single mention of the
System.Convert class, which puzzles me. If Convert is not used
implicitly by the language, then its relation to C# conversions is
unclear and it's unclear what one should use Convert for, at least in
C#. If it is implicitly used, then I guess we have a documentation bug
in the Standard or in the MS implementation of C#.

(While I am interested in the Convert case, I mentioned is just as an
example)

No, it's not used by the C# compiler. There are various cases where
Convert does things which "pure C#" can't do - converting strings into
integers, for example. Those are the primary uses of Convert in my
experience.
 

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