C# 9 und 10 – What’s cool?
Christian Nagel
https://csharp.christiannagel.com
Christian Nagel
• Training
• Coaching
• Consulting
• Development
• Microsoft MVP
• www.cninnovation.com
• csharp.christiannagel.com
• @christiannagel
Topics
• Nullable Reference Types
• Top level statements
• Records
• Source Generators
Nullable
Reference
Types
Phases
• C# 8: Nullable Adoption Phase
• Use nullable with libraries
• C# 9: Enhancements
• Attributes, Generics
• C# 10 / .NET 6
• Defaults with Templates
Nullable
Reference
Types
• New since C# 8: null state analysis
• Enhancements with C# 9
• Explicitly enable nullable (nullable
contexts)
• Nullable oblivious (C# 7.3 or earlier)
• #nullable (source code)
• <nullable> (project setting)
No fixes
with…
• Nullability doesn’t fix all issues!
• Arrays
• Structs…
Enhancements
• Attributes
• AllowNull, DisallowNull (Precondition)
• MaybeNull, NotNull (Postcondition)
• NotNullWhen, NotNullIfNotNull, MaybeNullWhen (Conditional post-condition)
• MemberNotNull, MemberNotNullWhen (Helper methods)
• Generics
• T? doesn’t require class or struct (C# 9)
• notnull, class?, default constraints
Top-Level Statements
New Hello World
• C# 6
• using static
• C# 9
• Top-Level Statements
• C# 10
• global using directives
• file scoped namespaces
• Implicit usings
Samples
• Hello, World!
• Empty Web
• Minimal API
Records
C# 9 -
Class
Records
• Nominal or Positional
• Equality Implementation
• init-only setters
• with expressions
• Deconstruction
C# 10 -
Struct
Records
• Nominal or Positional
• Equality Implementation
• init-only setters
• with expressions (all structs)
• Deconstruction
Samples
• Records with classes and structs
• Inheritance
• Records with EF Core
Source Generators
What are Source Generators?
• Invoked by the C# Compiler
• Generated code can be used by the application
• Enhanced partial keyword
Samples • Simple Source Generator
• .NET 6 JSON Serializer
There’s more…
C# 9
• Records
• Init-only setters
• Top-level statements
• Covariant return types
• Target-typed new expressions
• Pattern matching enhancements
• Static anonymous functions
• Attributes on local functions
• Extension GetEnumerator
• Lambda discard parameters
• Native sized integers
• Function pointers
• Module initializers
• Extensions for partial methods
• Source code generators
• Generic constraint changes for nullability
C# 10
• global using directives
• file-scoped namespaces
• Custom parameterless constructors with
structs
• Field and property initializers with structs
• with expression with structs
• record struct
• Lambda improvements (attributes, natural
delegate type)
• Extended property patterns
• Const interpolated strings
• Record types can seal ToString
• Assignment and declaration in the same
deconstruction
• Generic Attributes
• Templates change with new language
features and nullability
• Implicit Usings
• Static abstract members in interfaces
(preview)
Summary
• Nullable Reference Types
• Top-level statements
• Records
• Source Generators
Thank
you!
• Source code:
https://github.com/christiannagel
• More information:
https://csharp.christiannagel.com

More Related Content

PPTX
C# language
PDF
Reference Semantics with C# and .NET Core
PPTX
Introduction To C#
PPTX
.NET and C# introduction
PPTX
.NET and C# Introduction
PPTX
c# usage,applications and advantages
PPTX
C# programming language
PPTX
Introduction to .NET with C# @ university of wayamba
C# language
Reference Semantics with C# and .NET Core
Introduction To C#
.NET and C# introduction
.NET and C# Introduction
c# usage,applications and advantages
C# programming language
Introduction to .NET with C# @ university of wayamba

What's hot (20)

PPT
C#.NET
PPTX
Introduction to c#
PPT
C sharp
PPTX
Overview of microsoft dot net platforms
PDF
Object oriented-programming-in-c-sharp
PPT
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
PDF
The Spoofax Language Workbench (SPLASH 2010)
KEY
Language Engineering in the Cloud
PPT
10 Sep08 2003ver
PPTX
Programming Paradigm & Languages
KEY
Remix Your Language Tooling (JSConf.eu 2012)
PPT
Introduction to c_sharp
PDF
F# for Scala developers
PDF
Getting Started with TypeScript
PDF
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...
PDF
TypeScript: Angular's Secret Weapon
PDF
Typescript for the programmers who like javascript
PPTX
TypeScript - Silver Bullet for the Full-stack Developers
PPTX
TypeScript Overview
PDF
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017
C#.NET
Introduction to c#
C sharp
Overview of microsoft dot net platforms
Object oriented-programming-in-c-sharp
Trends in Programming Technology you might want to keep an eye on af Bent Tho...
The Spoofax Language Workbench (SPLASH 2010)
Language Engineering in the Cloud
10 Sep08 2003ver
Programming Paradigm & Languages
Remix Your Language Tooling (JSConf.eu 2012)
Introduction to c_sharp
F# for Scala developers
Getting Started with TypeScript
Integrated Language Definition Testing: Enabling Test-Driven Language Develop...
TypeScript: Angular's Secret Weapon
Typescript for the programmers who like javascript
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript Overview
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017
Ad

Similar to C# 9 and 10 - What's cool? (20)

PDF
C# 9 - What's the cool stuff? - BASTA! Spring 2021
PPTX
What's coming in c# 9.0
PPTX
What's new in C# 8.0 (beta)
PDF
C# 8 in Libraries and Applications - BASTA! Frankfurt 2020
PPTX
What's Coming in C# 9.0
PDF
C# 7.x What's new and what's coming with C# 8
PDF
Whats Newi in C# 8.0
PPTX
Bringing nullability into existing code - dammit is not the answer.pptx
PDF
C# 8 in Libraries and Applications
PPTX
What's coming to c# (Tel-Aviv, 2018)
PDF
C# - What's Next?
PPTX
.NET Foundation, Future of .NET and C#
PPTX
Evolution of c# - by K.Jegan
PPTX
Mini .net conf 2020
PPTX
PPTX
C sharp 8.0 new features
PPTX
C sharp 8.0 new features
ODP
(7) c sharp introduction_advanvced_features_part_ii
PPTX
F# as our day job by 2016
PDF
(4) c sharp introduction_object_orientation_part_i
C# 9 - What's the cool stuff? - BASTA! Spring 2021
What's coming in c# 9.0
What's new in C# 8.0 (beta)
C# 8 in Libraries and Applications - BASTA! Frankfurt 2020
What's Coming in C# 9.0
C# 7.x What's new and what's coming with C# 8
Whats Newi in C# 8.0
Bringing nullability into existing code - dammit is not the answer.pptx
C# 8 in Libraries and Applications
What's coming to c# (Tel-Aviv, 2018)
C# - What's Next?
.NET Foundation, Future of .NET and C#
Evolution of c# - by K.Jegan
Mini .net conf 2020
C sharp 8.0 new features
C sharp 8.0 new features
(7) c sharp introduction_advanvced_features_part_ii
F# as our day job by 2016
(4) c sharp introduction_object_orientation_part_i
Ad

More from Christian Nagel (17)

PDF
Async streams
PDF
Azure App Configuration with .NET applications
PDF
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
PDF
Entity Framework Core 1.x/2.x Advanced
PDF
Gemeinsame View-Models mit XAML Technologien
PDF
C# 8 and .NET Core 3
PDF
.NET Core 3.0 - What's new?
PDF
Adaptive Cards - User Interfaces with JSON
PDF
Reference Semantik mit C# und .NET Core - BASTA 2019
PDF
C# What's next? (7.x and 8.0)
PDF
Blazor - The New Silverlight?
PDF
Desktop Bridge with WPF - One way to build modern apps with WPF
PDF
C# - What's next
PDF
Business Apps with the Universal Windows Platform
PDF
Blazor - The New Silverlight?
PDF
Was is Docker? Or: Docker for Software Developers
PDF
Moderne Business Apps mit XAML - oder mit WPF für die Zukunft geplant
Async streams
Azure App Configuration with .NET applications
.NET Core Foundations - Dependency Injection, Logging & Configuration - BASTA...
Entity Framework Core 1.x/2.x Advanced
Gemeinsame View-Models mit XAML Technologien
C# 8 and .NET Core 3
.NET Core 3.0 - What's new?
Adaptive Cards - User Interfaces with JSON
Reference Semantik mit C# und .NET Core - BASTA 2019
C# What's next? (7.x and 8.0)
Blazor - The New Silverlight?
Desktop Bridge with WPF - One way to build modern apps with WPF
C# - What's next
Business Apps with the Universal Windows Platform
Blazor - The New Silverlight?
Was is Docker? Or: Docker for Software Developers
Moderne Business Apps mit XAML - oder mit WPF für die Zukunft geplant

Recently uploaded (20)

PPTX
Trending Python Topics for Data Visualization in 2025
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
Introduction to Windows Operating System
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
Computer Software and OS of computer science of grade 11.pptx
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Visual explanation of Dijkstra's Algorithm using Python
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Microsoft Office 365 Crack Download Free
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
Cybersecurity: Protecting the Digital World
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Trending Python Topics for Data Visualization in 2025
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
GSA Content Generator Crack (2025 Latest)
Designing Intelligence for the Shop Floor.pdf
iTop VPN Crack Latest Version Full Key 2025
Why Generative AI is the Future of Content, Code & Creativity?
Wondershare Recoverit Full Crack New Version (Latest 2025)
Patient Appointment Booking in Odoo with online payment
Introduction to Windows Operating System
Tech Workshop Escape Room Tech Workshop
Computer Software and OS of computer science of grade 11.pptx
How to Use SharePoint as an ISO-Compliant Document Management System
Visual explanation of Dijkstra's Algorithm using Python
Weekly report ppt - harsh dattuprasad patel.pptx
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Microsoft Office 365 Crack Download Free
Salesforce Agentforce AI Implementation.pdf
Cybersecurity: Protecting the Digital World
CCleaner 6.39.11548 Crack 2025 License Key
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev

C# 9 and 10 - What's cool?

  • 1. C# 9 und 10 – What’s cool? Christian Nagel https://csharp.christiannagel.com
  • 2. Christian Nagel • Training • Coaching • Consulting • Development • Microsoft MVP • www.cninnovation.com • csharp.christiannagel.com • @christiannagel
  • 3. Topics • Nullable Reference Types • Top level statements • Records • Source Generators
  • 5. Phases • C# 8: Nullable Adoption Phase • Use nullable with libraries • C# 9: Enhancements • Attributes, Generics • C# 10 / .NET 6 • Defaults with Templates
  • 6. Nullable Reference Types • New since C# 8: null state analysis • Enhancements with C# 9 • Explicitly enable nullable (nullable contexts) • Nullable oblivious (C# 7.3 or earlier) • #nullable (source code) • <nullable> (project setting)
  • 7. No fixes with… • Nullability doesn’t fix all issues! • Arrays • Structs…
  • 8. Enhancements • Attributes • AllowNull, DisallowNull (Precondition) • MaybeNull, NotNull (Postcondition) • NotNullWhen, NotNullIfNotNull, MaybeNullWhen (Conditional post-condition) • MemberNotNull, MemberNotNullWhen (Helper methods) • Generics • T? doesn’t require class or struct (C# 9) • notnull, class?, default constraints
  • 10. New Hello World • C# 6 • using static • C# 9 • Top-Level Statements • C# 10 • global using directives • file scoped namespaces • Implicit usings
  • 11. Samples • Hello, World! • Empty Web • Minimal API
  • 13. C# 9 - Class Records • Nominal or Positional • Equality Implementation • init-only setters • with expressions • Deconstruction
  • 14. C# 10 - Struct Records • Nominal or Positional • Equality Implementation • init-only setters • with expressions (all structs) • Deconstruction
  • 15. Samples • Records with classes and structs • Inheritance • Records with EF Core
  • 17. What are Source Generators? • Invoked by the C# Compiler • Generated code can be used by the application • Enhanced partial keyword
  • 18. Samples • Simple Source Generator • .NET 6 JSON Serializer
  • 20. C# 9 • Records • Init-only setters • Top-level statements • Covariant return types • Target-typed new expressions • Pattern matching enhancements • Static anonymous functions • Attributes on local functions • Extension GetEnumerator • Lambda discard parameters • Native sized integers • Function pointers • Module initializers • Extensions for partial methods • Source code generators • Generic constraint changes for nullability
  • 21. C# 10 • global using directives • file-scoped namespaces • Custom parameterless constructors with structs • Field and property initializers with structs • with expression with structs • record struct • Lambda improvements (attributes, natural delegate type) • Extended property patterns • Const interpolated strings • Record types can seal ToString • Assignment and declaration in the same deconstruction • Generic Attributes • Templates change with new language features and nullability • Implicit Usings • Static abstract members in interfaces (preview)
  • 22. Summary • Nullable Reference Types • Top-level statements • Records • Source Generators
  • 23. Thank you! • Source code: https://github.com/christiannagel • More information: https://csharp.christiannagel.com