What's new in C# 6.0

Sign in to queue

Description

C# 6 adds a lot of small but useful language features to remove boilerplate and clean up your code. This video takes you on a whirlwind tour through all the new language constructs.

Tags:

.NET, C#

Embed

Download

The Discussion

  • User profile image
    Nitin

    Feels like VB.Net belongs to Google :)

  • User profile image
    BlackTiger

    Changes remind me unreadable C++-style mess...

    Very often "simplification" very quickly turns into "stupidification". Still prefer to "read" my code instead of "decode" it.

  • User profile image
    Suave

    Killer features guys. Really allows for efficient code writing. Ignore the naysayers.

  • User profile image
    apivovar

    I was shocked within first three minutes :(

  • User profile image
    shankar

    really cool enhanced features

  • User profile image
    codepic

    , BlackTiger wrote

    Still prefer to "read" my code instead of "decode" it.

     

    I like to read my code instead of "interpret" it. Which is why I like most of the "simplification" herein.

  • User profile image
    ian4eto

    Just wonderful! How did we live by now :)

  • User profile image
    PatrickWolf

    Great enhancements to allow focusing on the intend and make code more concise!

  • User profile image
    CuriousRed​Monkey

    I like the null operator, but I think the IDE should call it out in the text (a bright color and maybe with bold).  Otherwise, it will be missed.  Not missed for when you have it there, but for when you forgot to put it in.  As a developer I will assume that I placed it there, but since it is not obvious in the sea of text I will miss it and all the consequences of not checking for null will propagate. 

  • User profile image
    Oleksandr Bilyk

    Guys. You have made mistake in presentation: OnChanged by Framework Design Guidelines should be method name (On<EventName>). So the syntax should be Changed?(this, args).

  • User profile image
    pavdro

    @BlackTiger:it's not changes... this is additions.

    None one forcing you to use it. Please keep negativity to yourself :)

  • User profile image
    Andy

    Creating another language ?????
    Useless enhancements !

  • User profile image
    Vlad Mysla

    All of the changes looks pretty straightforward. Especially Elvis operator ))) But is that's all what they can say about the Roslyn? Noo!! There has to be a way more videos about it

  • User profile image
    Sankalp

    Probably , C# is becoming now best and easy productive language.

  • User profile image
    mogo

    This is mostly looking great! As a language processing specialist, I'm gonna love string interpolation, very much so. And the Elvis operator? Thanks goodness! Got tired of these miles long conditions. I mean, it's obvious we're testing the value of foo ONLY if it is not null, so get rid of explicity there... However, I feel that some changes make stuff more simple but harder to decode especially within a team of heterogeneous coding style. e.g. I don't like it much when you remove curly braces outside of a then statement, it's about hierarchy and making distinctions but it's all a question of preference I guess.

  • User profile image
    pankajdehar​ia

    Great explanation of the features, easy to understand and point to point. thanks

  • User profile image
    r2dnb

    Nice features. I wish they added an operator to prevent method parameters from being null, I'm wondering why they really don't seem to be excited about doing it.

  • User profile image
    Mads​Torgersen

    @r2dnb: we are actually excited about adding better nullability checking to the compiler. If you check us out on GitHub, you can see some of our thoughts on that.

    It's not an easy thing, though, to add to a language that's out in its v6 already. It takes a lot of work for us to get it right, and that work takes time. But we are trying, and hopefully by C# 7 or C# 8 we will have worked it out and put it in the language!

     

     

     

     

  • User profile image
    Ima Dirty Troll

    Great stuff!  Can't wait to start using it, especially ?[], ?. and nameof().

    But all I really wanted was something to hide the sheer ugliness of dependency properties...

  • User profile image
    Zedn00

    Is this a joke? Where is a text rendition of this? I don't want to listen to some nerd spouting off over-enthusiastically at his own pace, I want to read ACTUAL text. Why is the world of Big Software assuming we all have the attention span of a week-old kitten and a similar level of literacy? WRITTEN WORDS - Rembember them? Sheesh.

  • User profile image
    Mads​Torgersen

    @Zedn00: That's because you are on Channel 9, which is a video site. I spouted some WRITTEN WORDS in various places, e.g. here.

    Thanks,

    The nerd

  • User profile image
    Hansjoerg

    this stuff really makes sense and the improvements are meaningful solutions.

  • User profile image
    Petras Surna

    The features are great but they make the language feel more bloated and less elegant as a result. They also confuse developers - I know as I employ a team of them and they get confused about each others code.

    C# now has the feel of a pensioner on crutches with a hip replacement and false teeth in order to get around.

    I think there is a call for a new cleaned up language without so many ways of doing things.

  • User profile image
    SuperE

    Love you guys!!

    The ?. syntax is like getting rid of that pebble in the shoe for a marathon runner.

    Thanks

    -E-

  • User profile image
    Jason Marshall

    Love_it{};

  • User profile image
    3Way

    NoOverhead?.WriteCleanerCode();
    :P

  • User profile image
    rik22

    I am baffled the way IT is now going.

    The whole aim of a successful development language is to make it maintainable.  To do this you have to have readable syntax and repeatable ways of doing things (one way of doing something).  However C# seems to be deliberately going in the other direction by introducing yet more ways of doing something that can already be done and inventing new code syntax, making code less readable.

    Adding new features to a language is good, but do not add features that effectively already exist.  Adding yet another way of doing something means more complication and more problems understanding and maintaining code.

    Simplicity and standardisation should be the aim, not complexity and ambiguity.

  • User profile image
    Joe

    I loved the video. For all of the complainers.....IT'S OPTIONALLY NOT MANDATORY. You can still program any way you or your company needs you to program. The newer features in C#6 has definitely helped plenty including myself. Less concise coding is just as good. I’ve already taken advantage of the nameof operator and I can’t wait to take advantage of the new “string interpolation”. I have no issues with strings as they are, but this is even better.

    I agree that null checking \null conditional operator “?” [only the Question Mark] should definitely take the form of a color, but I’m not complaining. It would stand out more with a color which leads to easier visibility. I’m definitely going to be using the “?.” A LOT.

    Everything looks great. I will have to get used to the exception filters. I do see the benefits.

    Now all we need is native code outside of Windows 10 Universal apps. Open that up and c# will have no time becoming a definite go to standard. Also we need more security for compiled assemblies. In other words a built-in obfuscator from Microsoft themselves.

  • User profile image
    rik22

    Sorry Joe, I cannot agree.

    Its optional, not madatory is exactly what is wrong.  If its optional it means that someone could/will use it, which means everyone now needs to know how to code things in yet another way.  This results in an unecessary learning curve, taking time, delaying projects and costing money.  It means non-standard code everywhere. 

    If you have one way of doing it (i.e. mandatory) you prevent this happening, saving money, speeding up development.

    This might be nice for hobbists or very small teams, but for enterprise programming, this is a nightmare.

    In my opinion, LINQ and Lambda should never have been added, as they weren't needed and just make code more unreadable.

  • User profile image
    Joe

    @rik22

    I accept your opinion as well as others. I hope you accept my opinion as well. I don’t feel that this adds a learning curve, at least not a “steep” learning curve that is confusing. If anything this code should add neatness and help programmers like myself to get rid of clutter. C# is very productive so adding helpful things as we’ve seen in C# 6.0 won’t hurt anyone.

    You feel that it’s going to hurt productivity and lead to “non-standard code everywhere”. I beg to differ due to rules such as coding standards. As I said if you work for a company that has a coding standard then follow THAT standard. Same goes for personal use. Just because certain people don’t like optional 6.0 features doesn’t mean MS shouldn’t continue to evolve for those who enjoy the updates.

    I love LINQ and Lambda’s. LINQ gives C# more life in the business sector. It’s also easy to use along with Visual Studios. If you don’t LINQ….DON’T USE IT. Easy as that. If you don’t like Lambda’s……..stay away from them. I personally love both. Single expressions can now be one line. That’s definitely going to clean up code. Func’s\Action’s\Lambda’s = greatness IMO. They are worth learning in my opinion and not hard at all. I’ve learned to love both query and fluent syntax.

    Also Lambda’s are boss for multithreading.

  • User profile image
    Johan

    I like the elvis operator a lot. The dollar sign reminds me of jquery though, not sure i like it. But i don't quite see how these changes warrant a new version of C# to 6.0.

  • User profile image
    Borodkin

    Nice!!!

    "nameof" rocks!!!

  • User profile image
    RogerKing

    I can bet allin that once you learn this new way of coding u will always use it. And if u see any code in the old fashion u will be very attempted to change it. Thats a clear sign that you guys hit on the nail!

    I was amazed that u got that done, just hope that C# 6.0 wont need Windows 10 platform.

    Gratz

  • User profile image
    Farid

    The ?. operator is the coolest one! I almost use it every time and it makes validations so much simpler. DotNet Rocks!

  • User profile image
    andrewosina​me

    Id say it looks like its converging with ruby,python and other modern languages.

  • User profile image
    JMarcelo

    Nice new features!! Each one of them!

    @rik22 I agree everybody will start to use them, but that's an indicative of how great they are. If you chose to be an IT professional, you gotta be ready to learn new stuff every day so I don't see any reason to complaint. Besides, the "pros" in these cases are a lot greater then the "cons".

    Null checking operator and string interpolation are much awaited features.

  • User profile image
    Vincent Johns

    @rik22: Can't the features that you would rather avoid using, as a matter of style, be suppressed or at least flagged with the help of an auditing utility? As I recall, at least for a while, JetBrains's ReSharper included a mechanism for refactoring LINQ expressions into strings of function calls. Anyway, it's possible to make any code look bad (as can be done automatically with an "obfuscator"), but for me, LINQ query expressions are much easier to read and understand than the method-call alternative if done well. De gustibus non disputandum est.

  • User profile image
    F J

    Cool! Really really Cool! keep going. C# is the best ;)

  • User profile image
    kishoresahas

    I like string interpolation :) 

  • User profile image
    cl0h

    @rik22 I think you shot yourself in the foot when you suggested that Linq and Lambdas shouldn't be in the language. I agree with you that there can be too many ways in a language to do things. This makes code hard to read and thus hard to maintain. I have believed for some time that C# is probably complete as far as syntax goes. At this stage the designers should be getting more conservative at adding stuff. The good news is that they have and there are just a small few additions in version 6.

    @Joe I think you may be confusing neatness with brevity. Sometimes more code is easier to read. It does take time to internalize new syntax and in a large or alien codebase it slows you down. Tools like Resharper have helped me grok new changes in the past. Resharper even ovffers to change iterations to linq statements and predicates to lambdas and stuff like that. This is probably unnecessary but it does help to grok how new changes work when you see the same piece of code done in two different ways.
    Of course this also exposes the fact that you probably don't need three ways o doing the same thing. As you argue you could just agree on standards within your enterprise and decide on when and if you move to the new syntax. It might just be easier to have one way of doing things and not get uptight about verbosity in your code (if your intent is clear).

  • User profile image
    skovacic

    Ooh, asynchronous try/catch!!

  • User profile image
    Oliver​Centeno

    Excellent set of features,

    at last static imports, inline string concatenation and elvis op! available in other languages

    Brackets for JObject can be improved a bit more with lambda expressions, why not using this?

    new JObtect(){ x = X, y = Y };

    or

    new JObtect(){ x => X, y => Y };

  • User profile image
    Carel

    Lol, All they need to do now is drop the curly braces and call it Python

  • User profile image
    docesam

    i heard this guy in MS DEV show podcast. i feel that those guy are super awesome. i feel the heavens of c# world.

     

    i am just little concerned about adding too many language stuff ,yes i mean the world of c++ complexity.. 

  • User profile image
    Hesamom

    ops! If I want to be honest , you made a dozen code into one code there for us :)

  • User profile image
    C Perkins

    Regarding the Elvis operator, Mads says "If null then null..." and "...the whole thing becomes null", but the whole expression for the if condition really becomes "If null then FALSE". That statement might be okay for other languages, but C# is still a strongly-typed language and the if statement demands a boolean value--it does not handle null values directly. After more investigation it seems that the null-conditional operator really turns the expression into a nullable expression like int? or bool?, etc. But that still doesn't explain exactly what goes on because the if statement (or any other strictly boolean operation) still cannot accept nullable types either. Starting from C#2, it appears that many boolean operators are overloaded to accept nullable types but Visual Studio Intellisense naively shows only the standard value type overloads and "hides" the implicit handling of the nullable types.

    It's easy to just dismiss this nitpicking, but truly understanding how to program in any language eventually demands understanding the minutia. If documentation explained this it would be okay, but even MSDN C# reference doesn't explain it.

  • User profile image
    Asif Patankar

    Started in being love with C# AGAIN!!!

  • User profile image
    Pascal Ried

    @rik22, @Joe I'd like to join your opinions.

    I think they/you should add options for saying "I want to allow this feature / disallow this feature in my file/project/solution/IDE" So that VS even only reacts on special syntax, when it is allowed. Then, you could just not even get bothered with new/fluid ways of coding. And others, who dislike "the oldschool way" could just use the other option.

    Also the team might want to focus next on easy to use and understandable ways to help use/see the new things even better.
    Maybe by clicking on a old-way-coded function and saying "simplify" (don't forget the other way around, though).
    Maybe make it as a quick-preview, so if I want to look at a file, my mate coded with $"{x}" it can only-show me the whole file in old-style string.Format("{0}",x) (I wouldn't need to learn the new thing to understand what's going on).

    Thanks for the great video and the new features of C#. I think I will find use for both systems in different kind of tasks.

    Also it is great for developers who come from JavaScript or PHP and thus it will be more easily to connect different languages into one project, without too much difference in syntax only.

  • User profile image
    jalal uddin

    it's really cool.

  • User profile image
    xCyborg

    I really like all those features geared towards making the code more easy and concise, I thank God you didn't introduce any weird API-bound concepts.

    @MadsTorgerse​n And call me a lazy geek, but I love those tiny videos so much, and even the text with the Github Wiki section, this is the right call. I love that all the magic is in one single github repository with all the docs right there.

    I can't wait to contribute to C# 7 if it's not too late.

  • User profile image
    sandero

    Great explanation and great features. I like smaller more readable code!

  • User profile image
    Quoc Ly

    Well done ! This is most value in relation to the study of how a society organizes conspiracy ! thanks for all of that Sir !

  • User profile image
    Deactivated User

    thats a great inovation, wiped the language and made it simpler to do the implementing!

  • User profile image
    Smartmil8

    @Nitin: I've just noticed some further changes to the proposed features of C# 6.0 which I don't think have been announced previously, Firstly, interpolated strings are going to be convertible to IFormattable which will enable them to be formatted later for a specific locale.

  • User profile image
    Taco

    This guy needs to learn how to talk. It is PROPERTIES, not PROBERTIES..

  • User profile image
    onyx

    should have made auto property with INotificationChange from behind

  • User profile image
    Roy

    The "Elvis"-operator looks more like David Bowie when he was Ziggy Stardust.

  • User profile image
    Sam

    The ? Null Operator is a copy from GOSU!

  • User profile image
    Tom

    Very good presentation. Thanks.

  • User profile image
    Himanshu Patel

    Still I am not able to run c# 6.0 project on VS 2013. Where is the simplicity? I agree with the new features but what about backward compatibility?

Add Your 2 Cents