Entries:
Comments:
Discussions:

Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

What's New In C# 6.0

7 minutes, 7 seconds

Download

Right click “Save as…”

Slides (view online)

C# 6.0 adds about a dozen bite-sized new features to C#, all aimed at making your code cleaner and clearer. Instead of introducing new concepts, each feature makes a common coding pattern simpler, and removes boilerplate to let the intent of the code stand out. The video takes a quick tour through the new features: auto-properties without setters, methods and properties with expression bodies, member access that protects against null, interpolated strings and much more.

For more information, check out this course on Microsoft Virtual Academy:

Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
    Unsubscribing
    Subscribing
  • Juan PabloJuan Pablo

    C# 6.0 is like writing art. All the changes I watched make the code even more productive, and I was really waiting for an await in catchs. Thank's a lot! :)

  • chrischris

    Great vid! Gotta love the new features!

  • Now this is great! Thanks Mads!

  • MarceloMarcelo

    Oh Man! Mads should have his own selling channel on TV haha

  • I love every one of these features.

    What a nice, simple upgrade to C#. All small but useful.

    I think the ?. operator is my favorite - this simple operator will actually decrease the number of null refs found in production code. String literals make for much simpler code, makes the intent pop. nameof is quite welcomed, too! And expression method bodies will make for more succinct classes.

    Nice work, Mads and team!

  • KintarKintar

    WHY are these things always videos? I just want to read it, not listen to someone talk for seven minutes about something I can read in 90 seconds. :/

  • Joe ChungJoe Chung

    Fantastic! Can't wait!

  • Really succinct presentation Mads.  Got everything I needed to know in a few minutes instead of a whole hour of demos.  Good work. :)

  • Spencer DragerSpencer Drager

    Great video. I'm very excited to start using these latest features. I love that this version focused on reducing the code of common scenarios... It is going to make a great language even better!

  • Turning csharp into perlTurning csharp into perl

    You've essentially taken perfectly clear code and made it unreadable for anyone who isn't a C# expert. Or in other words, you've basically turned C# into Perl.

  • Drag SorensonDrag Sorenson

    This was exactly what I was thinking. We're a rather large company with thousands of employees and while we use C# for the majority of our development a lot of people won't be able to read things like the ?. operator.

    Maybe they're mainly into analytics, design, testing or maybe they are simply not reading up on C# updates in their spare time. The simple fact is that we need all sorts of people to be able to quickly assess code which isn't necessarily written by themselves. This isn't going to be helped by hotshot PERL like shortcuts.

    I've know a lot of circles who pride themselves in making code as short as possible, but I think that is a horrible practice. Especially for enterprise solutions where you have to deal with reality rather than utopia.

    As management I know my employees are not as good or as up-to-date as I would like them to be. We still need to make * work, however, and only way to do that efficiently is to make sure everyone does their best to write code which is readable by everyone. Some of these C# 6.0 features are the direct opposite of that.

  • mdkmdk

    Great update, great presentation, very succinct!

    The null conditional operator is _exactly_ what was needed, that was a major pain point in the language and will be a great productivity boost.

    Using lambdas for single line methods or poperties, does not seem too useful to me, as I tend to write them in one line as well anyway by just moving the curly braces up. 2 curly braces vs. the lambda arrow saves you only the "return" statement - not a lot of overhead.

    The inlining of the string format arguments is a nice one - you lose the ability to easily repeat arguments, but I can't even remember the last time I needed that and it gets rid of those StringFormatExceptions that you only notice at runtime if you happen to forget a parameter, so that's a very good trade imho.

    I disagree strongly with all opponents of change, first: one cannot stop progress, if the language is not kept up to date, every smart person or anyone concerned about productivity will switch to other languages that do. Trying to cater to the slowest learner will get you stuck with those and keep the smarter ones at bay.

    Even if you don't agree, consider this: adding lambdas to the language was a way bigger change and I can remember the lamentation back then - but where are they now?

    Take care,
    Martin

  • nokonoko

    @Drag Sorenson, well the solution to that is easy, right? Just hold a class in your company and teach them the whole 5 or 6 new things in C# 6. It will only take 7:07 minutes.

  • @Kintar - I don't like videos either :) All of Mads' material is on the C#/VB project site here in a lot more depth - https://roslyn.codeplex.com/wikipage?title=Language%20Feature%20Status

    Also we'll be putting up a blog post about the new features early next week - http://blogs.msdn.com/b/csharpfaq/

     

  • @Turning csharp into perl:That's just silly. You need to understand basic programming to read it. I guess if your brain has been atrophied by laziness then perhaps it's too difficult. 

    Why add anything to a language if the lowest common denominator can't understand it? Goodbye generics and lambda expressions. Let's keep it painfully stupid, am I right?

    It literally takes less than 5 minutes to wrap your mind around this new null check syntax. 

  • @Drag Sorenson:Seriously?

    1. Fire anyone that can't read a ?. operator. Those people shouldn't be programmers and they are most certainly doing more harm than good. 

    2.  You don't HAVE to write it that way and I'm sure all the horrible corporate policies out there willl decree that...omg...don't use ?. , it's soooo mysterious, we're going to have to call in the expert Egyptologists to decipher this mystery. Maybe we'll allow it in 10 years after the scientists and mathematicians  thoroughly study this strange and impenetrable new form of Calculus.   It's a GOD DAM Null condition operator!!!!! We're not calculating a moon landing here!!

     

     

  • If you wish to enforce a team policy that no one is allowed to use ?. there's now a really easy way to do it. Look at Alex's video about "analyzers": http://channel9.msdn.com/Events/Visual-Studio/Connect-event-2014/714

    It will take you about 30 minutes to write an analyzer that enforces the rule "no ?. is allowed". You can add the analyzer as a reference to your projects. This will give a compile-time error (both on dev machines and on your team build server) anytime anyone uses the ?. operator.

     

  • Hey, I fully understand the concern that new short hands can lead to more convoluted code. There are many short hands we could consider adding to C#. We are extremely careful to only add ones that we think lead to more clarity in common code.

    With any new opportunity to compact code, there's going to be people eager to overuse it. It's a bit of an organizational challenge to establish what good code looks like, and how these new features can be used responsibly, in a way that fits the culture of the company.

    That said, we don't feel we have a choice but to evolve the language to improve developers' productivity and better meet new challenges. We try to take a balanced approach, so that C# can keep growing for a long time without collapsing under its own weight. But grow it will.

    Thanks for all the wonderful comments, both good and bad ones!

  • elman alievelman aliev

    C# now is nice!
    Thanks.

  • Edgar FroesEdgar Froes

    Nicely done!

    Is this already available? Like in the Update 4 of VS 2013 that came out just recently.

  • peterpeter

    Static using is for me useless. This just creating chaos in code.

  • MarkMark

    I'm very excited about JObject, Nullable check for values, and the Exception filters. Awesome job guys, can't wait to get my hands on this in the next release.

  • Lee DaleLee_Dale .nettter

    Static using is for me useless. This just creating chaos in code.

    I agree this can only detract from readability, it's a pretty pointless feature if you ask me.

    But I welcome the other changes, I really like exception filters and lambda expression bodies.

  • PeterPeter

    @Lee_Dale: yes i see this as you.
    All features are good but that static using :/

    Second i do not know why they still propagate primary constructors after they removed them from this release of C# and roslyn compiler :/

    Please MS add codelens to smaller editions too (at least to premium). It make sense add this feature to smaller editions. There are no lot ppl who can get Ultimate ://

  • Edward MoemekaMoemeka Me

    Um, what happened to the $ shortcut for dictionary initializers that have a string based key.  I get the squiggles when I try to use it.  This is a critical issue for data access types as you noted in a previous blog.  I am tired of creating one-off data classes that are just extensions of some back end projection.  The $ feature was a nice middle ground since anonymous types can still not be serialized properly.

  • AkosAkos

    I have a question about the ?. operator example. After the change, aren't we checking if json is null twice? I mean we're replacing 1 "json != null" check with 2 "json?"...

  • Arman McHitaryanArman McHitaryan

    Good job done at c# team! 10x, guys. It's really appreciated how you do your best to keep the language up to date and still looking Sharp, as it says.
    C# is my fav language, I'm on one :)
    I was hoping for the primary .ctor not to pass the design committee since it wasn't fitting the overall look and feel of the language, at least to me and the way it was originally propagated.

    Static using is definitely not to overuse, the additional part before the dot in the name of the function gives you more idiomatic name. Or that was the way we've been thinking of it so far. You most of times want to see what this or that method belongs to. But will be useful in some certain scenarios, where it's just clear per se. Like with the Math class, for instance.

    Other than that, the new features really rock. Love them all. We love to have guidelines at C# and it gives us even more expression :)

    And after all, we have Elvis in c# what could have been better? :) Elvis is alive and "grow it will"! nice stuff there. thanks for tremendous work.

  • @Moemeka: The $index feature got dropped. It got a pretty ambiguous reception, and we had doubts about whether it was the right way to go about things.

  • @Akos: Yes, the example now checks for null twice.

  • Great vid! Gotta love the new features!

    Agree, but.. is this still the best way to debug an auto-property?

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/b1dd0dc3-e9c1-402a-9c79-a5abf7f7286a/setting-a-breakpoint-on-a-c-property-written-in-the-short-hand-syntax?forum=vsdebug

    :S

     

  • vivek chauhanvivek chauhan

    Great features

  • Edward MoemekaMoemeka Me

    @MadsTorgersen:Thanks for you feedback, this request might be too late but please consider making anonymous types like new{Name="john",Age=5}; serializable by generating a public parameterless constructor for them and also marking the type with the appropriate DataMember/Contract attributes.  They are already public types and cannot be redefined at runtime so why not make them seriazable?  This reduces code bloat astronomically.

  • Certainly, Great Features!

  • BrunaBruna

    Cool but I have to agree with Kintar.

  • chosenbreedchosenbreed

    Cool set of features. What version of the runtime will they be in?

  • Alexandre trepanierAlexandre trepanier

    It's all nice really appreciate all this but everybody is waiting for

    1. first class awaitable composable events (observables) would have been added to c# in the language(it's a mess at the moment in code.. patterns need to be added into the language itself)

    2. Pattern matching

    3. domain-specific language DSL integrated to c# (so we can get rid of XAML and replace it with a cleaner UI declarative DSL) (mostly already possible with extensions method to create fluent interface but a real DSL can redefine everything)

    also cleaner tupple, union types, enum as generic type

    -----
    and we are going very near to scala at that point.. or f# with cleaner c# syntax

  • Alexandre TrepanierAlexandre Trepanier

    why not tweak F# to become a full dsl language and afterwards just redefine the dsl into c# so both c# and f# become one under the shell

    this way all goodies added to F# could be added easily to C# in one or two iteration..

    F# is nice but i don't like the syntax and also the way you define lambas..

    (param1type -> param2type -> returntype)

    all over the doc and everywhere.. soooo unreadable..

    scala is a lot better by using ( (param1type,param2type) -> resulttype)

    (int,int) -> int is a lot clearer than int -> int -> int

    might seem stupid but with lambas with lambas as params like in observable\reactive coding. it become a real mess to understand what is being passed where..

    it's the main reason i will never really be into f# ..

    also i find it's too different from c# so it twist the mind when you use both at the same time..

  • Alexandre TrepanierAlexandre Trepanier

    Also when will you clean the documentation portion of classes..

    the xml doc comments, or comments etc are the worst piece of crap ever that it makes everybody wanna puke..

    make visual studio able to hide those comments and put them into a doc comment panel for classes or something.. with easier way to create your doc for intellisence etc..

    and why not add dependency injection directly into the c# language

  • Alexandre TrepanierAlexandre Trepanier

    Mads Torgersen hire me ;)

    would be awesome to work with a cool genious like you

  • I still don't know what exactly the Java world thinks it has on C#/.NET... this is very quickly becoming Direct3D vs OpenGL where Microsoft entertained the illusion of an even match for a little bit in the beginning...

  • "If you wish to enforce a team policy that no one is allowed to use ?. there's now a really easy way to do it."

    @ljw1004:Hey now don't be waving guns around in crowded rooms.

  • Donovan BrownDonovan Senior DevOps Program Manager

    To me these new features are just additional tools in my tool box and when they make sense I will use them. I did not see any old features removed for these features, just these features added. Therefore, if you don't like them or can't read them simply don't use them.  Just because all you need is a hammer does not mean the rest of the world can't use screw drivers. They are just additional tools.

  • I like most of the new features. However, I agree that this could add to more convoluted code depending who is looking at the code.

    @MadsTorgensen "With any new opportunity to compact code, there's going to be people eager to overuse it. It's a bit of an organizational challenge to establish what good code looks like, and how these new features can be used responsibly, in a way that fits the culture of the company."

    What I've learned in the past 29 years of using different programming languages is that one can create hard to read code in "every" programming language that is out there. Microsoft has the responsibility to walk that fine line to very carefully introduce new features. With version 6.0, I think most of the new features are overkill and not really required. 

    "That said, we don't feel we have a choice but to evolve the language to improve developers' productivity and better meet new challenges."

    I disagree 100%. Readability of code is a productivity concern much more so than short-hand typing. If most developers can not read some  source right away, you have lost productivity. The programmer who used these PERL shortcuts may have saved a few seconds of typing, but the clarity of the code may be lost for other developers. 

    Again, I personally like the new features but I can see where the majority of developers especially in enterprises will introduce even more convoluted code now thanks to these PERL short-cuts that introduce harder to "read" code.

  • Great to see more features that make the language more succinct and expressive with less lines of code.

  • Joe GbadamosiJoe Gbadamosi

    C# looks nicer with these new features.
    Thanks for the short and straight to the point video.

  • kesmuhcnokesmuhcno





  • Silvio SilvaSilvio Silva

    Love C# and it's syntax sugar but in respect to semantic versioning this one would rather be called C# 5.1

  • SteveSteve

    I love seeing all the new changes. For all these though, why can't you guys fix issues around build process? Surely it wouldn't take much to add the following which frustrate many development teams every day...

    1. Be able to use msbuild properties for a projects output path.
    2. Have a pre and post solution build step which is supported by both msbuild and visual studio. This is really important for large projects and for being able to abstract differences between CI and desktop deployments.
    3. True support for high dpi in winforms (I know it's not sexy but a lot of companies have millions of lines of code around winforms and wpf had too many performance problems to switch). As high dpi monitors become the norm, unless MS wants to bleed more customers to mac you will really need to get a good answer for the latter. What I would like to see is a full point based drawing system for gdi+ (not all commands support points), a better built in resource management approach for handling images at different dpi levels (similar to what is available in Xcode) and a constraint based layout system also like in Xcode.

    Thanks for listening,
    Steve
    Microsoft Alumni

Remove this comment

Remove this thread

Close

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.