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# / December 2007

Tip: Looking for answers? Try searching our database.

new features in c# 3

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DAXU@hotmail.com - 07 Dec 2007 11:20 GMT
Hi,

I just read some blogs which listed new features of c# 3.0. They
listed things like Automatic Properties,Object Initializers etc.

But frankly I do not see big changes from c# 2. It is not like in c#
2, they finally give us generics. Compare c# 2 to c# 1.1, generics is
something huge.
But I read part of c# 3 specifications, I don't have this feeling yet.

Maybe I missed something? Whould some one point it out for me?

Many Thanks

Jerry
Marc Gravell - 07 Dec 2007 11:46 GMT
And you'd be right... to a point ;-p

The C# 3 changes are largely (on the surface) some minor compiler
conveniences - but good conveniences. Extension methods, for instance,
I've already used in a number of scenarios completely unrelated to
LINQ. Many of the features tie tightly to eachother - for instance,
anonymous types demand the "var" type inference. Lambdas (as
delegated) feel cleaner than the older syntax, but yes: *by itself* it
isn't a killer feature (although the facility to compiler to an
Expression rather than a delegate is /extremely/ powerful - but
obviously demands .NET 3.5 [which C# 3 itself doesn't]).

However, the features really come into their own when considered with
their relationship with LINQ (.NET 3.5). Almost everything in C# 3
relates to LINQ in some way, so it is hard to evaluate their use
without some mention of LINQ. I started typing an "in particular", but
to be honest so much of the changes tie to LINQ that it became
unnecessary. Maybe auto-properties don't tie to LINQ... but that's
about it...

Regardless of your thoughts of LINQ-to-SQL etc, LINQ surely represents
an extremely powerful and expressive step forward, which hopefully
will make it easier for code to indicate what it is trying to achieve,
rather than masses of step-by-step how to do it.

This again important if you want to use things like PFX (or Parallel
Extensions, whatever they are calling it now), which is important
given the migration towards multi-core computing - the compiler can't
do anything with overly-specific code, but if you express your intent
and let the framework worry about implementation (rather than having
to continually write lots of parallel plumbing, and making lots of
mistakes in the bargain) you are onto a winner.

If you are interested in more information about the C# 3 particulars
and their advantages [or just more info], rather than focusing on
the .NET 3.5 details [which are of course mentioned, but only to
explain the "what?" and "why?"], then I can recommend Jon Skeet's
forthcoming book - it is /heavily/ geared toward the language rather
than the framework.

http://www.manning.com/skeet/

Marc
Marc Gravell - 07 Dec 2007 13:17 GMT
One other comment; remember that there is no CLI/CLR update for C# 3,
so there aren't any huge new concepts like generics; everything fits
mainly as compiler tricks within the existing frameworks (CLR 2.0),
with some optional features (Expression compilation) drawing from
framework updates (.NET 3.5). But no IL changes.

The default LINQ providers obviously draw from .NET 3.5, but this is
not tied directly to the compiler; the extension methods etc just
happen to pick them up according to the langauge spec. You can write a
LINQ-to-objects implementation in .NET 2.0, for example.

Marc
Jon Skeet [C# MVP] - 07 Dec 2007 13:35 GMT
On Dec 7, 11:20 am, D...@hotmail.com wrote:
> I just read some blogs which listed new features of c# 3.0. They
> listed things like Automatic Properties,Object Initializers etc.
[quoted text clipped - 5 lines]
>
> Maybe I missed something? Whould some one point it out for me?

As Marc pointed out, there are no CLR changes like generics and
nullable types in 2.0. However, I think that LINQ (and indeed lambda
expressions in general) will actually make *more* of a change to how
we code. Rather than being a refinement of existing style, C# 3
encourages you to think more functionally/declaratively.

It's up to you, of course - you can choose to use C# 3 as if nothing
had changed, but you'll be missing out :)

Of course, I second Marc's recommendation of my book, by the way ;)

Jon
Alun Harford - 08 Dec 2007 15:43 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>
> Maybe I missed something? Whould some one point it out for me?

I think the change is huge - particularly lambda expressions.

If I'm writing C# 2 code for other developers to use, I'm not likely to
expose a method that takes a delegate to control some aspect of that
method (I'd do that internally, but methods I expose to other developers
would take an object implementing an interface which basically wraps the
delegate in a method).

In C# 3, I'd be quite happy to expose a method taking a Func because
people know to supply a lambda (and they don't need to know the details
about how it works).

That's a pretty big change - at least as much as generics.

Alun Harford
Jon Skeet [C# MVP] - 08 Dec 2007 17:34 GMT
<snip>

> In C# 3, I'd be quite happy to expose a method taking a Func because
> people know to supply a lambda (and they don't need to know the details
> about how it works).

I think there are some details they don't need to know about, and some
they do. The exact procedure of type inference is really complicated
now, for instance - and most of the time you really don't need to know
what the compiler's doing. Captured variables, on the other hand, can
radically affect how your program behaves, and if you start using them
without being aware of them you could have a real problem on your
hands.

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.