No video

My favorite new features in C# 9 (.NET 5)

  Рет қаралды 26,086

DotNet Core Central

DotNet Core Central

Күн бұрын

This week .NET Conference 2020 took held between 10-12 November. During the conference, .NET 5 and C# 9.0 was officially released.
In this video, I am going to walk through three features of C# 9.0, which are my favorite ones.
And they are:
1. Init only setters
2. Record types
3. Top-level statements
In my opinion, Record type will be one of the most used features of C# 9.0. It is at least my favorite one. Creating an immutable type was never been so easy.
Init only setters are the enabler behind the record types. It is the feature that is used internally to achieve the feature of the record type.
Top-level statements also are going to be highly used, especially when working with serverless technologies like Azure functions or AWS Lambda.
Last year I did a video on my top 5 favorite features of C# 8.0, you can check it out on KZbin here: • Top Five C# 8 Features...
My blog site where I write exclusively about .NET Core (.NET 5 going forward) is here: dotnetcorecent...

Пікірлер: 60
@paulohincdig
@paulohincdig 3 жыл бұрын
Thank you for your explanation and the way you make it so easy.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Paulo Duarte, thanks for watching!
@davidharrington1133
@davidharrington1133 2 жыл бұрын
ToString() on a record also has a sensible string description by default.
@saurabhchauhan232
@saurabhchauhan232 3 жыл бұрын
Very nice simple and clear examples
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Saurabh Chauhan, thanks for watching!
@techrelated2417
@techrelated2417 3 жыл бұрын
Very useful and easy to understand. Thanks for the video!!
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Tech Related, thanks for watching!
@elliottevan9348
@elliottevan9348 3 жыл бұрын
I guess I am quite randomly asking but does anyone know of a good site to stream newly released movies online ?
@VijayKumar-wy9ku
@VijayKumar-wy9ku Жыл бұрын
Top notch content!
@DotNetCoreCentral
@DotNetCoreCentral Жыл бұрын
Thanks!
@christophertanghare4884
@christophertanghare4884 3 жыл бұрын
Thanks for the video 😁 great job
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Christopher Tanghare, thanks!
@ashutoshsoni3017
@ashutoshsoni3017 3 жыл бұрын
very quick and simple explanation. Thanks Brother.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Ashutosh Soni, thanks for watching!
@errrzarrr
@errrzarrr 3 жыл бұрын
_init_ keyword: I think we already have OOP encapsulation and access modifiers ( _private_ keyword) for that. Also, what about _const_ and _readonly_ keywords then, what are they for?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Roberto M., to my understanding, init, const, and read-only are three very different and distinct features. init - allowed to set only using objection initialization, where the property value is not set through a constructor. Hence it works similar to how a real-only and constructor based object initialization works with a property based initialization scenario. Hence at a very high level conceptually it is the same read-only, but in terms of implementation, it is very different. Both promote immutability at their core. const - on the other hand, is to define compiled time and is a class-level variable that is constant in nature. Also, you can consider const = static read-only.
@aj.arunkumar
@aj.arunkumar 3 жыл бұрын
Nice one... But when we remove the Program class and Main method, shouldn't be there an error 'args not defined' ... ? or is it like args the default name for cmd line args...?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Arun Kumar A.J, The framework automatically creates string[] args and passes it to the top-level calls, and that is why the compiler does not complain about it.
@davimezalira
@davimezalira 2 жыл бұрын
Very useful.. tks
@DotNetCoreCentral
@DotNetCoreCentral 2 жыл бұрын
@Davi Mezalira, thanks for watching!
@gopalakrishnanm9349
@gopalakrishnanm9349 3 жыл бұрын
Nice.pls put a video for major changes in dotnet 5 Because I don't know why I'm using dotnet 5 instead of dotnet 3.1
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Gopi HB, thanks for watching. And I will surely do a video on .NET 5 changes.
@gopalakrishnanm9349
@gopalakrishnanm9349 3 жыл бұрын
@@DotNetCoreCentral thanks
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@gopalakrishnanm9349 you are welcome!
@mahi-lapse
@mahi-lapse 3 жыл бұрын
Simple and nice explanation, thanks
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Mahi Uddin, thanks for watching!
@sujitwarrier4857
@sujitwarrier4857 3 жыл бұрын
"with" is like the spread operator in Javascript
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Sujit Warrier, to my understanding with and spread, are nothing alike. To my understanding spread in JavaScript is similar to Ranges in C#
@anassnassim
@anassnassim 3 жыл бұрын
Thanks for the video what is the best path for creating a website with asp .net core what I should learn?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Anass nasim, in my opinion, a JavaScript SPA framework like Angular or React is a better option for creating a website, whereas you can use .NET Web API for REST services providing data to the website. The Blazor web assembly is also an option, but I am currently exploring it and not yet convinced it's a better alternative to JavaScript.
@hkpeaks
@hkpeaks 3 жыл бұрын
C# is amazing, using c# to read 70MB CSV file with data row 1,000,000 => only 1.1 second, plus generate web summary report => 1.2 second
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Freeware Web BI Tool 【你快 youFast】thanks for watching!
@AshishSingh146
@AshishSingh146 3 жыл бұрын
Thanks you 4 explanation.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Ashish Singh, thanks for watching!
@subrataranjanpal6518
@subrataranjanpal6518 3 жыл бұрын
Wonderful !!!
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Subrata Ranjan Pal, thanks for watching!
@rynox77
@rynox77 3 жыл бұрын
Using the with example, is a new instance of the record constructed or, put another way, is memory allocated for an additional instance of the record with the "with" statement? It must be if records are immutable, right?
@rynox77
@rynox77 3 жыл бұрын
Also, what are the ramifications of using the special case pattern with record types?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Ryan McAtee, a new instance of the record is created (with additional memory allocation). As you guessed since it's immutable by design.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@rynox77 I do not think there is any. What kind of ramifications you are thinking that might be a side effect?
@rynox77
@rynox77 3 жыл бұрын
@@DotNetCoreCentral Given the following: record Person(string FirstName, string LastName); It looks like for my special case, record PersonNotFound : Person... it requires the constructor public PersonNotFound() : base(default, default) { }.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@rynox77 I would be interested in knowing what is the special case, just out of curiosity. I have not come across this situation yet, but it's of course too early.
@rajkgoel77
@rajkgoel77 3 жыл бұрын
Using 'with' statement can we join multiple instances of different classes? If yes, how would it work in case of overlapping property names? Also, would methods from these different instances be available in newly created instance?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Khaleefa, no you cannot join, it is more like inheritance than join. So you can use "with" keyword only with one record type. The answer to your second question is yes.
@ProperComment
@ProperComment 3 жыл бұрын
Just wow!!
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@The Red Baron, thanks!
@user-ir5vb7vv5e
@user-ir5vb7vv5e 3 жыл бұрын
Thank you
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Александр Бабаев, thank you for watching the video!
@Flaflo
@Flaflo 3 жыл бұрын
I am glad they are taking features from kotlin over to c# thats really nice.
@chezchezchezchez
@chezchezchezchez 3 жыл бұрын
Which features?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Flaflo, Thanks for watching! As far as I know, features like record type existed in functional programming languages like Scala and F# way before kotlin was even created. But I might be wrong.
@errrzarrr
@errrzarrr 3 жыл бұрын
I think they are general concepts. That's what I think.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@errrzarrr thanks for watching the video.
@LuigiZambetti
@LuigiZambetti 3 жыл бұрын
Why don't you make a playlist on Blazor or developing web applications with .NET 5.0?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Luigi Zambetti, I will create on, thanks for the suggestion.
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Nothing IsReal I can try this out in future episodes when I start my series on AWS and Azure.
@voswouter87
@voswouter87 3 жыл бұрын
Why is .net not cls compliant?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@Wouter Vos, thanks for watching the video. I am not sure I understand your question. CLS is for languages, and .NET Framework enforces the CLS compliance, so CLS is meaningless without .NET so to speak. And if you meant about C#, then C# is 100% CLS compliant, otherwise, it will not be able to run inside a .NET compiler. I hope this answers your question.
@voswouter87
@voswouter87 3 жыл бұрын
@@DotNetCoreCentral The coding style at my company includes CLS compliance as a good practice for better code. However when using code from ASP.NET Core almost everything isn't, so we end up having to turn it off. Does ASP.NET Core also have many external imports? I'd expect not and thus it would be very easy to make it CLS compliant. What would be lost if it was?
@DotNetCoreCentral
@DotNetCoreCentral 3 жыл бұрын
@@voswouter87 Hi, I am sorry, but I am still not able to understand what all in ASP.NET Core is CLS Compliant, so it is hard for me to say how different it will be in .NET 5.
Async/Await an Introduction (Asynchronous programming in .NET 5.0)
18:13
DotNet Core Central
Рет қаралды 16 М.
5 New Features in C# 9 (not including Records)
1:11:00
IAmTimCorey
Рет қаралды 81 М.
❌Разве такое возможно? #story
01:00
Кэри Найс
Рет қаралды 3,6 МЛН
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 12 МЛН
The Future of .NET is .NET 5 | DB123
29:33
Microsoft Events
Рет қаралды 117 М.
Что нового в C# 9
42:11
Platinum DEV
Рет қаралды 4,6 М.
Every single feature added in C# 11
27:07
Nick Chapsas
Рет қаралды 111 М.
Message between components using MediatR [C# 11 / .NET 7]
11:46
DotNet Core Central
Рет қаралды 5 М.
Every New Feature Added in C# 12
14:19
Nick Chapsas
Рет қаралды 150 М.
Intro to Records in C# 9 - How To Use Records And When To Use Them
1:19:44
C# 9 New Features | New Features of C# 9.0 Part 1
32:18
sekhar srinivas
Рет қаралды 10 М.
THIS stops 90% of C# Developers Learning TDD
19:40
Gui Ferreira
Рет қаралды 13 М.
8 await async mistakes that you SHOULD avoid in .NET
21:13
Nick Chapsas
Рет қаралды 311 М.
❌Разве такое возможно? #story
01:00
Кэри Найс
Рет қаралды 3,6 МЛН