C# 10 A Sneaky Peek 👀

HELLO! I am Stuart Lang You can find me at https://stu.dev DMs open!

Quick Recap

C# 9 Recap

C# 9 Recap › › › › Top-level Statements Records Pattern Matching Enhancements Source Generators

› .NET 6 Preview 7 › https://aka.ms/dotnet-download

› LINQPad 6 beta › Go to Edit | Preferences > Query › Check “Use Roslyn Daily build”

› https://sharplab.io › Select the Roslyn branch dropdown › Pick “main”

File Scoped Namespaces 7

Global Usings

Console app

Worker app

Web app

Record Structs

SharpLab Example: https://sharplab.io/#v2:EYLgtghglgdgNAExAagD4AEBMBGAsAKAIHoiA3CAJwAIBnAF0roAUB7GqOqFmKgXipgBTAO5UAwixYUEsCHUE0AFNjiYAlAG5iZSgJGt2nbn1oMKzNhy49hHABZUA3gBk5JgCwBfLfhLpsAJyKQsIGVtyaBAQUggDGUgimFACusXTiktKy8koILMnAADaCVK50cFR5BcWl3ADmkYS+RPQpaRkJ2QqO6ADMlflFJWVOdYJ0GrAcGp5UfQPVw/Wj45Mw057eQA

More on Records Records Deep Dive: What, Why and How - David Wengier - NDC Melbourne 2021: https://www.youtube.com/watch?v=lxwNcg2q1-Y 27

Better Lambdas

Before…

Natural Inferred Types for Lambdas

Explicit Lambda Return Types

Lambda Attributes

Minimal APIs

With our powers combined…

The Simplest API

Source: Damian Edwards

Source: Damian Edwards

Caller Expression Attribute

Caller Attributes Recap › [CallerMemberName] › [CallerFilePath] › [CallerLineNumber]

CallerArgementExpression

String Interpolation Improvements

Const Interpolation

String Interpolation Handler

String Interpolation Handler

String Interpolation Handler

Extended Property Pattern

Extended Property Pattern

Required Properties C# 11

!! (Bang Bang) C# 11

Raw String Literals C# 11

Raw String Literals

Generic Attributes C# 11

Generic Attributes

Static Abstracts in Interfaces In Preview

More Resources › .NET 5 & C# 9 Talk - https://drive.google.com/file/d/1IZg12xyrtsH8OPIfpWYl9zlyIUjAhmmq/view?usp=sharing › C# Language Design - https://github.com/dotnet/csharplang/ › Language Feature Status - https://github.com/dotnet/roslyn/blob/main/docs/Language%20Feature%20Status.md › Mads Torgersen Talk - C# 10 - https://www.youtube.com/watch?v=HCiY2Ubm3yA

THANKS! Any questions? You can find me at: @stuartblang · https://stu.dev