Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Which .net features exactly are exposed through the language?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
igivanovg@gmail.com - 25 Feb 2008 19:11 GMT
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!
---------
Igor
Jon Skeet [C# MVP] - 25 Feb 2008 20:01 GMT
> Example: msdn says explicitly that enumerable/enumerators are exposed
> via foreach. It says so a thousand times everywhere. Ok.
[quoted text clipped - 4 lines]
> 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.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Marc Gravell - 25 Feb 2008 20:02 GMT
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[<T>] (15.8.4 of ECMA 334)

> 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
igivanovg@gmail.com - 25 Feb 2008 21:04 GMT
> 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)

------------
Igor
Jon Skeet [C# MVP] - 25 Feb 2008 22:07 GMT
> > I suspect that it uses the implicit/explicit conversion operators
> > defined for the types in question; see 8.2.2 of ECMA 334
[quoted text clipped - 8 lines]
> (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.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.