The top 10 best new features in C# version 6 to 9 - Chris Klug

preview_player
Показать описание
There is a lot of cool, and usable new features being added to C#. However, way too many of us are too busy building stuff, and fixing/creating bugs, to have the time to sit down and look take it all in. So why not let Chris Klug walk you through his top 10 new features that have been added in C# version 6 to 9.

Sure, C# has gotten a LOT more than 10 new things since version 6. But if you are a busy developer, like most of us are, getting an introduction to the top 10 ones in just an hour, could be a great start.

In this talk, Chris will show, and explain, his personal top 10 favorite features that have been added to C# in the last few years. Everything from awesome time savers and stability contributors, to syntax changes that allow your code to be denser and/or easier to read.
Рекомендации по теме
Комментарии
Автор

1) String Interpolation 6:32 ||| $"Hello {worldvar}";
2) Default Interface Methods 9:17
3) Out Variables 12:35 ||| Avoiding having to declare out variable before using it.
4) Expression Bodied Members 14:32 ||| Doing get set better.
5) Discards 18:36 ||| Allows calling functions that return a type async w/o warnings
_ = await DoSomething(); //discard the returned value
_ = name ?? throw new ArgumentNullException(...); //avoids having to check for null in extra lines of code
6) Null-conditional operator 25:18
if != null) instead of 3x if conditions checking for null
6.5) null-coalescing assignment 27:30 ||| options ??= MyOptions.Default;
7) Nullable Reference Types 29:30 ||| must enable nullable types manually to use them ( 31:50 )
33:44 myFunction(string? value) must write parameters this way to avoid warnings with nullable ref types enabled to indicate to compiler you are aware this can now potentially be null
8) Named Tuples 37:37 ||| tuples can be useful to return 2 values from function but...
39:22 has non-descriptive identifiers myTuple.Item1 when using them outside function
so in C#7 named tuples: var testInfo = myFunction(string studentName, int gradeAverage) allows testInfo.studentName and testInfo.gradeAverage
42:15 the change from declaring variables in lines of code; to inlining variables to shorten code; to var (myString, myInt) = myTupleReturningFunction();
43:10 comparing tuples will compare values of properties, not property names
49:40 pattern matching on tuples
10) 51:37 Record Types ||| turning a lengthy, code-verbose object: 52:40 ...into: public record Order(Int Id, string ArticleName, decimal Total);
54:40 make a specific part of the immutable record type mutable by using "with" keyword
11) rest of the talk is just extra that I didn't watch

digitalconsciousness
Автор

Wow such evolving language C# 10 is around the corners.

sps
Автор

That guy: "I have OCD"
Also that guy: "I use var everywhere"
...I hate that guy.

Erikulum