C# Language Highlights: Records

  Рет қаралды 12,313

dotnet

dotnet

Күн бұрын

Records is a new language feature introduced in C# 9.0. In this short video, Jasmine ( / paladique ) and Kendra ( / gotheap ) show us how it works.
🏫 Free self-guided learning for C# on Microsoft Learn: aka.ms/learn/c...
Create Records types
docs.microsoft...
Records (C# reference)
docs.microsoft...
First steps with C#
docs.microsoft...
Get your questions answered on the Microsoft Q&A for .NET - aka.ms/dotnet-qa​
Learn .NET with free self-guided learning from Microsoft Learn: aka.ms/learndotnet
#DotNet

Пікірлер: 30
@igor19781978
@igor19781978 3 жыл бұрын
Keep them coming, love the short and interactive format
@karimmohamed8001
@karimmohamed8001 2 жыл бұрын
100!!!
@tcopling
@tcopling 3 жыл бұрын
I enjoy the simplistic way records is explained and the style of these videos. Awesome.
@jshawmain3337
@jshawmain3337 3 жыл бұрын
Thank the gods for representation. I have always been the only black dev my entire career. U 2 are awesome!
@MechanicalMooCow
@MechanicalMooCow 3 жыл бұрын
Lmao stfu
@calvinwilson3617
@calvinwilson3617 3 жыл бұрын
Something else that may deserve its own highlight is the record "with" keyword to copy and override specific properies. That was a gamechanger when i started working with state management in blazor, especially with the init setter
@josda1000
@josda1000 3 жыл бұрын
Cant wait to use this at work. We are still working on c# 7.3 which isnt bad but again, i cant wait
@OeHomestead
@OeHomestead 3 жыл бұрын
Using records when ever I can in my projects and they're definitely making things a lot easier :-) DebuggerDisplay straight outta the box, support for attributes, init-setters, etc.
@danielvelkov116
@danielvelkov116 3 жыл бұрын
So basically you define the the props, class name and default constructor all in 1 line!? Cool
@intcoder
@intcoder 3 жыл бұрын
Great Stuff!!
@Dazza_Doo
@Dazza_Doo 2 жыл бұрын
2:40 "I've made IceCream abstract" - how? Line 16 says otherwise, since you called it directly? Clarification needed, ta Understand the Other Records are inheriting from (base) IceCream internal record IceCream(string Flavour, string Colour) - would make this abstract? or does it need to be Protected? or am I off Base here?
@KibbleWhite
@KibbleWhite 3 жыл бұрын
Yay Ice Cream! Also thanks for the video :)
@vindjedouatchomba7742
@vindjedouatchomba7742 3 жыл бұрын
Nice!
@jkone27
@jkone27 3 жыл бұрын
One on F# :) pls
@Edvard-Aliev
@Edvard-Aliev 3 жыл бұрын
Первый! Спасибо за видео!
@cleancoder3838
@cleancoder3838 3 жыл бұрын
you're not telling me that one is saying "I don't remember how class comparison works" and surprise, there is a prepared example to show... that "I don't remember how it works" looks pretty much staged, isn't it? besides that, good demo.
@karimmohamed8001
@karimmohamed8001 2 жыл бұрын
Bro, of course it is. They did it in case someone (probably newbie/beginner) gets confused or forgets how it was with "class". Cuz one can confuse and say "Wait, how is that any different with the class?". Reminder only.
@fallonmassey4714
@fallonmassey4714 3 жыл бұрын
How do you use this in a web world where converting to json, etc. is required?
@tea_otomo
@tea_otomo 3 жыл бұрын
I don't see the point. Yes, there are classes that only are used for data, but this can change very quickly and you add some methods, logic, and so on to them. Even when they are mostly used for Data, there are often just master classes that are used in every "data class".
@cadikaorade828
@cadikaorade828 3 жыл бұрын
AFAIK at compile time the record is converted into a class so you can consider it a syntactic sugar designed to reduce boilerplate the dev has to type out. If you don't need all the features of a class you define a record as a one-liner instead. If you're content typing out a whole class definition with a ToString override that properly serializes, you can still do that.
@magic4218
@magic4218 3 жыл бұрын
IMO, classes just used for data should not contain any logic inside them.
@michahoffmann8992
@michahoffmann8992 3 жыл бұрын
If I'm not wrong the record is immutable, while the class is not.
@calvinwilson3617
@calvinwilson3617 3 жыл бұрын
Think of records as just classes which the compiler performs additional things automatically. The compiler creates the automatic tostring method and compares values. The real power is that you dont need to write the comparrison logic yourself, just use the record keyword and c# generates that code for you. You can now pass that value to a logger and it will automatically convert to json in the .tostring. i hqve also found the with keyword to copy a record but override specific properies in a single concise statement. Ex var email2 = email1 with { subject = "copy: " + email1.subject }; it reduces your code by a significant amount
@angel_machariel
@angel_machariel Жыл бұрын
Irrelevant code at the end. var c = NuttyIceCream has nothing to do with the subject! You should have displayed that in the case of class references, their address differ! That's why the two objects are different. As opposed to "records", where the addresses of two objects, but with same data, remains the same. In other words, it was relevant to actually display the addresses of both dictionary objects (holding same data), and both the class objects (holding same data).
@rubickon
@rubickon Ай бұрын
really great
@chefbennyj
@chefbennyj 3 жыл бұрын
This is interesting. I didn't see the examples print to console in the video. Hey, what do records look like when you serialize them to json?
@TheMannihilator
@TheMannihilator 3 жыл бұрын
records are just compiler generated classes
@chefbennyj
@chefbennyj 3 жыл бұрын
@@TheMannihilator cool, that's what I figured. Many thanks.
@kosteash
@kosteash 3 жыл бұрын
what for plagin in vs has Kendra ?
C# Language Highlights: Nullable Reference Types
5:24
dotnet
Рет қаралды 27 М.
C# 9 Language Features
22:39
dotnet
Рет қаралды 62 М.
А ВЫ ЛЮБИТЕ ШКОЛУ?? #shorts
00:20
Паша Осадчий
Рет қаралды 9 МЛН
My daughter is creative when it comes to eating food #funny #comedy #cute #baby#smart girl
00:17
What are record types in C# and how they ACTUALLY work
15:36
Nick Chapsas
Рет қаралды 121 М.
Coding Shorts: For The Record - Why You Should Use (Records in C#)
10:46
Shawn Wildermuth
Рет қаралды 12 М.
C# Value vs Reference Types Explained
6:40
Mark Inman
Рет қаралды 3,2 М.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 63 М.
C# Tutorial. Records - What They are and How to Use Them
16:10
Nick Proud
Рет қаралды 1,9 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 196 М.
What's new in C# 10
29:28
dotnet
Рет қаралды 87 М.
А ВЫ ЛЮБИТЕ ШКОЛУ?? #shorts
00:20
Паша Осадчий
Рет қаралды 9 МЛН